]> Sergey Matveev's repositories - path-extractor.git/commitdiff
Add tests for file surrounded by `()`
authorEdgar HIPP <hipp.edg@gmail.com>
Sun, 30 Aug 2015 15:06:58 +0000 (17:06 +0200)
committerEdgar HIPP <hipp.edg@gmail.com>
Sun, 30 Aug 2015 15:06:58 +0000 (17:06 +0200)
extractor.go
pe_test.go
validators.go

index d42bf0e0032767a5203c4f5ae72383dd0385436f..6a87ab454cc79fb3a2b5daee2ceb52206850e64c 100644 (file)
@@ -3,8 +3,8 @@ package pathextractor
 import "regexp"
 
 func pathExtractor(input string) [][][]byte {
-       surroundRegex := "[^][ \\t:'\"]"
-       r := regexp.MustCompile("(" + surroundRegex + "*[\\./]" + surroundRegex + "*)")
+       surroundRegex := "[^][ \\t:'\"]*"
+       r := regexp.MustCompile("(" + surroundRegex + "[\\./]" + surroundRegex + ")")
        temp := [][][]byte{}
        temp = r.FindAllSubmatch([]byte(input), -1)
        return temp
index 58c138fc877e173254de4f87f73afeba02df93a3..844a0e56a69255fb5c2bd59185dc468df7729cde 100644 (file)
@@ -73,6 +73,16 @@ func TestGitIgnore(t *testing.T) {
                t.Errorf("Doesnt match multi", output)
        }
 
+       output = GetAllMatches("user.test.js")
+       if len(output) != 1 {
+               t.Errorf("Doesnt match multiple extensions", output)
+       }
+
+       output = GetAllMatches("(user.js)")
+       if len(output) != 1 {
+               t.Errorf("Doesnt match surrounded by parens", output)
+       }
+
        output = GetAllMatches("var/")
        if len(output) != 1 {
                t.Errorf("Doesnt match dir", output)
index b0501d6839111588ad0bfb4903b597ad41a0c77e..adc811666613f33c9c5c9aae31f6a390f2d66170 100644 (file)
@@ -67,7 +67,7 @@ func endsWithInvalidString(input string) bool {
 }
 
 func containsInvalidString(input string) bool {
-       invalidStrings := []string{"(", ")", "and/or", "origin/", "{", "}", "<", ">", "$", "*", "this."}
+       invalidStrings := []string{"()", "and/or", "origin/", "{", "}", "<", ">", "$", "*", "this."}
        for _, s := range invalidStrings {
                if strings.Contains(input, s) {
                        return true