diff --git a/parser.go b/parser.go index 9e8716a..b3b67ea 100644 --- a/parser.go +++ b/parser.go @@ -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 } diff --git a/utils.go b/utils.go index a24f4f4..0fe3777 100644 --- a/utils.go +++ b/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 -}