Split code into smaller parts within the auth package

This commit is contained in:
Pavel Korotkov 2020-07-21 12:40:46 +03:00
parent 6c0ddca8d0
commit ea7286c875
3 changed files with 62 additions and 50 deletions

19
auth/regexp-utils.go Normal file
View file

@ -0,0 +1,19 @@
package auth
import "regexp"
type regexpSubmatcher struct {
re *regexp.Regexp
}
func (resm *regexpSubmatcher) getSubmatches(target string) map[string]string {
matches := resm.re.FindStringSubmatch(target)
l := len(matches)
submatches := make(map[string]string, l)
for i, name := range resm.re.SubexpNames() {
if i > 0 && i <= l {
submatches[name] = matches[i]
}
}
return submatches
}