]> Sergey Matveev's repositories - path-extractor.git/commitdiff
Correct tests
authorEdgar HIPP <hipp.edg@gmail.com>
Sat, 16 Jan 2016 07:27:24 +0000 (08:27 +0100)
committerEdgar HIPP <hipp.edg@gmail.com>
Sat, 16 Jan 2016 07:27:24 +0000 (08:27 +0100)
extractor.go
validators.go

index 11161a31f2795feb2d0b8b3bb591e295586d1c97..0a1036186b132f4efe7edb9e1dfe3ca957595df1 100644 (file)
@@ -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) {
index 5f67fdbc47851f7a3812d02b63799cf9175a2368..38704c79ee284d5e5239afde882fab9d0823778b 100644 (file)
@@ -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