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, format string) []string {
33 options := MatchOptions{format: format}
35 candidatePath := string("")
36 restOfLine := string("")
37 indexes := pathExtractor(input)
38 for _, index := range indexes {
39 candidatePath = input[index[0]:index[1]]
40 if len(input) >= len(candidatePath+"(") && strings.Index(input, candidatePath+"(") != -1 {
44 if isIp(candidatePath) || isEmail(candidatePath) || isDate(candidatePath) || isVersion(candidatePath) || isGitRange(candidatePath) || isGitInstruction(candidatePath) || startsWithInvalidString(candidatePath) || endsWithInvalidString(candidatePath) || containsInvalidString(candidatePath) || len(candidatePath) <= 2 || isSpace(candidatePath) {
47 if isGitPath(candidatePath) {
48 candidatePath = replaceGitPath(candidatePath)
50 candidatePath = postProcess(candidatePath)
51 if options.format == "ackmate" {
52 restOfLine = input[index[1]:]
53 cursorPos := getCursorPosition(restOfLine)
54 candidatePath = fmt.Sprint(candidatePath, cursorPos)
56 result = append(result, candidatePath)
61 func getCursorPosition(input string) string {
62 r := regexp.MustCompile("^(:[0-9]+(:[0-9]+)?)")
64 temp = r.FindSubmatch([]byte(input))
68 return string(temp[1])