]> Sergey Matveev's repositories - path-extractor.git/commitdiff
Add ip adress regression
authorEdgar HIPP <hipp.edg@gmail.com>
Thu, 21 Jan 2016 22:42:20 +0000 (23:42 +0100)
committerEdgar HIPP <hipp.edg@gmail.com>
Thu, 21 Jan 2016 22:42:20 +0000 (23:42 +0100)
extractor.go
pe_test.go
validators.go

index 0a1036186b132f4efe7edb9e1dfe3ca957595df1..a17bf8a69cee0209dc03c37be21a073683c84dcc 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 || isSpace(candidatePath) {
+               if isIp(candidatePath) || 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 bc07d279b695c12fb8f8c33e1cd2cc7f6efde3be..d6dfaa6160746bf3196b1de200ace90b2fecd7c0 100644 (file)
@@ -33,6 +33,11 @@ func TestEverything(t *testing.T) {
                t.Errorf("Matches sentence", output)
        }
 
+       output = GetAllMatches("0.0.0.0:3000", "")
+       if len(output) != 0 {
+               t.Errorf("Match ipadress", output)
+       }
+
        output = GetAllMatches("'/usr/bin", "")
        if output[0] != "/usr/bin" {
                t.Errorf("Doesn't match statement correctly", output)
index 60a817c9beb239988faf277b377626d0ba467900..df6daf5c5a1f74750050fbd947ba495baef616b2 100644 (file)
@@ -51,6 +51,11 @@ func replaceGitPath(input string) string {
        return string(temp[1])
 }
 
+func isIp(input string) bool {
+       r := regexp.MustCompile("^[0-9]{1,3}\\.[0-9x]{1,3}\\.[0-9x]{1,3}\\.[0-9x]{1,3}$")
+       return r.Match([]byte(input))
+}
+
 func isVersion(input string) bool {
        r := regexp.MustCompile("^v?[0-9x]{1,3}\\.[0-9x]{1,3}(\\.[0-9x]{1,3})?$")
        return r.Match([]byte(input))