From: Edgar HIPP Date: Sun, 30 Aug 2015 15:07:03 +0000 (+0200) Subject: Correct tests X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=5083a5b6082be731123903af694a938d895a5a8f;p=path-extractor.git Correct tests --- 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 }