From: Edgar HIPP Date: Sat, 16 Jan 2016 07:27:24 +0000 (+0100) Subject: Correct tests X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=176b4e29e490f65f1acf5247daf711737c9c43b3;hp=379287d887d112d09e6482a7683f2261b293376d;p=path-extractor.git Correct tests --- diff --git a/extractor.go b/extractor.go index 11161a3..0a10361 100644 --- a/extractor.go +++ b/extractor.go @@ -41,7 +41,7 @@ func GetAllMatches(input string, format string) []string { continue } - if isEmail(candidatePath) || isDate(candidatePath) || isVersion(candidatePath) || isGitRange(candidatePath) || isGitInstruction(candidatePath) || startsWithInvalidString(candidatePath) || endsWithInvalidString(candidatePath) || containsInvalidString(candidatePath) || len(candidatePath) <= 2 { + if isEmail(candidatePath) || isDate(candidatePath) || isVersion(candidatePath) || isGitRange(candidatePath) || isGitInstruction(candidatePath) || startsWithInvalidString(candidatePath) || endsWithInvalidString(candidatePath) || containsInvalidString(candidatePath) || len(candidatePath) <= 2 || isSpace(candidatePath) { continue } if isGitPath(candidatePath) { diff --git a/validators.go b/validators.go index 5f67fdb..38704c7 100644 --- a/validators.go +++ b/validators.go @@ -56,6 +56,11 @@ func isVersion(input string) bool { return r.Match([]byte(input)) } +func isSpace(input string) bool { + r := regexp.MustCompile("^[0-9]*\\.[0-9]+[MGK]$") + return r.Match([]byte(input)) +} + func startsWithInvalidString(input string) bool { invalidBeginnings := []string{"Error/", "Object.", "Array."} for _, s := range invalidBeginnings { @@ -77,7 +82,7 @@ func endsWithInvalidString(input string) bool { } func containsInvalidString(input string) bool { - invalidStrings := []string{"//", "()", "and/or", "origin/", "{", "}", "<", ">", "$", "*", "this."} + invalidStrings := []string{"//", "()", "and/or", "remotes/", "origin/", "{", "}", "<", ">", "$", "*", "this."} for _, s := range invalidStrings { if strings.Contains(input, s) { return true