]> Sergey Matveev's repositories - path-extractor.git/blobdiff - extractor.go
Add check for invalid strings
[path-extractor.git] / extractor.go
index c19b7d5cae73c091b2f8e4599b17cd98461cd7aa..11161a31f2795feb2d0b8b3bb591e295586d1c97 100644 (file)
@@ -29,7 +29,8 @@ func postProcess(input string) string {
        return input
 }
 
-func GetAllMatches(input string, options MatchOptions) []string {
+func GetAllMatches(input string, format string) []string {
+       options := MatchOptions{format: format}
        result := []string{}
        candidatePath := string("")
        restOfLine := string("")
@@ -40,7 +41,7 @@ func GetAllMatches(input string, options MatchOptions) []string {
                        continue
                }
 
-               if isEmail(candidatePath) || isDate(candidatePath) || isVersion(candidatePath) || isGitRange(candidatePath) || isGitInstruction(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 {
                        continue
                }
                if isGitPath(candidatePath) {
@@ -58,7 +59,7 @@ func GetAllMatches(input string, options MatchOptions) []string {
 }
 
 func getCursorPosition(input string) string {
-       r := regexp.MustCompile("^(:[0-9]+(:[0-9]+)?)$")
+       r := regexp.MustCompile("^(:[0-9]+(:[0-9]+)?)")
        temp := [][]byte{}
        temp = r.FindSubmatch([]byte(input))
        if len(temp) <= 1 {