7 type MatchOptions struct {
11 func pathExtractor(input string) [][]int {
12 surroundRegex := "[@~\\-_a-zA-Z/.0-9]*"
13 r := regexp.MustCompile("(" + surroundRegex + "[\\./]" + surroundRegex + ")")
14 return r.FindAllSubmatchIndex([]byte(input), -1)
17 func stripParens(input string) string {
18 r := regexp.MustCompile("^\\((.*)\\)$")
20 temp = r.FindSubmatch([]byte(input))
24 return string(temp[1])
27 func postProcess(input string) string {
28 input = stripParens(input)
32 func GetAllMatches(input string, options MatchOptions) []string {
34 candidatePath := string("")
35 restOfLine := string("")
36 indexes := pathExtractor(input)
37 for _, index := range indexes {
38 candidatePath = input[index[0]:index[1]]
39 if len(input) >= len(candidatePath+"(") && strings.Index(input, candidatePath+"(") != -1 {
43 if isEmail(candidatePath) || isDate(candidatePath) || isVersion(candidatePath) || isGitRange(candidatePath) || isGitInstruction(candidatePath) || endsWithInvalidString(candidatePath) || containsInvalidString(candidatePath) || len(candidatePath) <= 2 {
46 if isGitPath(candidatePath) {
47 candidatePath = replaceGitPath(candidatePath)
49 candidatePath = postProcess(candidatePath)
50 if options.format == "ackmate" {
51 restOfLine = input[index[1]:]
52 cursorPos := getCursorPosition(restOfLine)
53 candidatePath = fmt.Sprint(candidatePath, cursorPos)
55 result = append(result, candidatePath)
60 func getCursorPosition(input string) string {
61 r := regexp.MustCompile("^(:[0-9]+(:[0-9]+)?)$")
63 temp = r.FindSubmatch([]byte(input))
67 return string(temp[1])