extractor.go | 17 ++++++++++++++++- pe_test.go | 3 +++ diff --git a/extractor.go b/extractor.go index 6a87ab454cc79fb3a2b5daee2ceb52206850e64c..ac819dc0081fdfe3cd5fb1ac5b7b74c093697930 100644 --- a/extractor.go +++ b/extractor.go @@ -10,6 +10,21 @@ temp = r.FindAllSubmatch([]byte(input), -1) 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 @@ } if isGitPath(s) { s = replaceGitPath(s) } - result = append(result, s) + result = append(result, postProcess(s)) } return result } diff --git a/pe_test.go b/pe_test.go index 844a0e56a69255fb5c2bd59185dc468df7729cde..6038afe9722e3f1fe3ee805737abed9e83e7e4cd 100644 --- a/pe_test.go +++ b/pe_test.go @@ -82,6 +82,9 @@ output = GetAllMatches("(user.js)") 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 {