Remove useless compileRegex function
Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
3a4aba93e5
commit
40b0ba999a
2 changed files with 2 additions and 13 deletions
|
@ -25,13 +25,13 @@ type Parser struct {
|
|||
func NewParser(includeRegex string, excludeRegex string) (*Parser, error) {
|
||||
|
||||
log.Debugf("compiling include name regex")
|
||||
includeRegexCompiled, err := compileRegex(includeRegex)
|
||||
includeRegexCompiled, err := regexp.Compile(includeRegex)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugf("compiling exclude name regex")
|
||||
excludeRegexCompiled, err := compileRegex(excludeRegex)
|
||||
excludeRegexCompiled, err := regexp.Compile(excludeRegex)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
11
utils.go
11
utils.go
|
@ -16,14 +16,3 @@ func ExtractShopName(link string) (name string, err error) {
|
|||
re := regexp.MustCompile(`^www\.`)
|
||||
return strings.ToLower(re.ReplaceAllString(u.Hostname(), "")), nil
|
||||
}
|
||||
|
||||
// compileRegex transforms a regex from string to regexp instance
|
||||
func compileRegex(pattern string) (regex *regexp.Regexp, err error) {
|
||||
if pattern != "" {
|
||||
regex, err = regexp.Compile(pattern)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return regex, nil
|
||||
}
|
||||
|
|
Reference in a new issue