diff --git a/internal/lsp/link.go b/internal/lsp/link.go index 86e6084074b..90d152fb34a 100644 --- a/internal/lsp/link.go +++ b/internal/lsp/link.go @@ -91,13 +91,15 @@ func findLinksInString(src string, pos token.Pos, view source.View, mapper *prot if err != nil { return nil, errors.Errorf("cannot create regexp for links: %s", err.Error()) } - for _, urlIndex := range re.FindAllIndex([]byte(src), -1) { + indexUrl := re.FindAllIndex([]byte(src), -1) + for _, urlIndex := range indexUrl { + var target string start := urlIndex[0] end := urlIndex[1] startPos := token.Pos(int(pos) + start) endPos := token.Pos(int(pos) + end) - target := src[start:end] - l, err := toProtocolLink(view, mapper, target, startPos, endPos) + target = src[start:end] + l, err := toProtocolLink(view, mapper, target, startPos, endPos) if err != nil { return nil, err } @@ -106,7 +108,7 @@ func findLinksInString(src string, pos token.Pos, view source.View, mapper *prot return links, nil } -const urlRegexpString = "(http|ftp|https)://([\\w_-]+(?:(?:\\.[\\w_-]+)+))([\\w.,@?^=%&:/~+#-]*[\\w@?^=%&/~+#-])?" +const urlRegexpString = "((http|ftp|https)://)?([\\w_-]+(?:(?:\\.[\\w_-]+)+))([\\w.,@?^=%&:/~+#-]*[\\w@?^=%&/~+#-])?" var ( urlRegexp *regexp.Regexp