From 5083a5b6082be731123903af694a938d895a5a8f Mon Sep 17 00:00:00 2001 From: Edgar HIPP Date: Sun, 30 Aug 2015 17:07:03 +0200 Subject: [PATCH] Correct tests --- extractor.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extractor.go b/extractor.go index 2a3b2cd..19bc274 100644 --- a/extractor.go +++ b/extractor.go @@ -1,6 +1,7 @@ package pathextractor import "regexp" +import "strings" import "fmt" type MatchOptions struct { @@ -8,7 +9,7 @@ type MatchOptions struct { } func pathExtractor(input string) [][][]byte { - surroundRegex := "[^][ \\t:'\"]*" + surroundRegex := "[^]()[ \\t:'\"]*" r := regexp.MustCompile("(" + surroundRegex + "[\\./]" + surroundRegex + ")") temp := [][][]byte{} temp = r.FindAllSubmatch([]byte(input), -1) @@ -38,6 +39,10 @@ func GetAllMatches(input string, options MatchOptions) []string { matches = pathExtractor(input) for _, match := range matches { s = string(match[1]) + if len(input) >= len(s+"(") && strings.Index(input, s+"(") != -1 { + continue + } + if isEmail(s) || isDate(s) || isVersion(s) || isGitRange(s) || isGitInstruction(s) || endsWithInvalidString(s) || containsInvalidString(s) || len(s) <= 2 { continue } -- 2.48.1