From 40b0ba999a6dd2ceb1ee8039867797f700c22b42 Mon Sep 17 00:00:00 2001 From: Julien Riou Date: Sat, 27 Feb 2021 15:14:21 +0100 Subject: [PATCH] Remove useless compileRegex function Signed-off-by: Julien Riou --- parser.go | 4 ++-- utils.go | 11 ----------- 2 files changed, 2 insertions(+), 13 deletions(-) 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 -}