Archived
1
0
Fork 0

Remove useless compileRegex function

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2021-02-27 15:14:21 +01:00
parent 3a4aba93e5
commit 40b0ba999a
No known key found for this signature in database
GPG key ID: FF42D23B580C89F7
2 changed files with 2 additions and 13 deletions

View file

@ -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
}

View file

@ -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
}