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

index 6a87ab454cc79fb3a2b5daee2ceb52206850e64c..ac819dc0081fdfe3cd5fb1ac5b7b74c093697930 100644 (file)
@@ -10,6 +10,21 @@ func pathExtractor(input string) [][][]byte {
        return temp
 }
 
+func stripParens(input string) string {
+       r := regexp.MustCompile("^\\((.*)\\)$")
+       temp := [][]byte{}
+       temp = r.FindSubmatch([]byte(input))
+       if len(temp) <= 1 {
+               return input
+       }
+       return string(temp[1])
+}
+
+func postProcess(input string) string {
+       input = stripParens(input)
+       return input
+}
+
 func GetAllMatches(input string) []string {
        matches := [][][]byte{}
        result := []string{}
@@ -23,7 +38,7 @@ func GetAllMatches(input string) []string {
                if isGitPath(s) {
                        s = replaceGitPath(s)
                }
-               result = append(result, s)
+               result = append(result, postProcess(s))
        }
        return result
 }
index 844a0e56a69255fb5c2bd59185dc468df7729cde..6038afe9722e3f1fe3ee805737abed9e83e7e4cd 100644 (file)
@@ -82,6 +82,9 @@ func TestGitIgnore(t *testing.T) {
        if len(output) != 1 {
                t.Errorf("Doesnt match surrounded by parens", output)
        }
+       if output[0] != "user.js" {
+               t.Errorf("matches surrounded by parens badly", output)
+       }
 
        output = GetAllMatches("var/")
        if len(output) != 1 {