blob: 634efe7bc81f87534942dd75635061d588c787be [file] [log] [blame]
Leopold506b8862023-01-31 14:54:13 +01001Ask commentwrap to ignore lines that contain HTTP URIs.
2Wrapping URLs is not useful and makes them not clicky in editors.
3
4---
5diff --git a/commentwrap.go b/commentwrap.go
6index a1e8c00..5491064 100644
7--- a/commentwrap.go
8+++ b/commentwrap.go
9@@ -86,6 +86,10 @@ func mustFlow(g *ast.CommentGroup, limit int) bool {
10 if strings.HasPrefix(comment.Text, "/*") {
11 return false
12 }
13+ // Ignore lines that are URIs.
14+ if isURI(comment.Text) {
15+ continue
16+ }
17 if len(comment.Text) > limit {
18 exceed = true
19 }
20@@ -156,6 +160,11 @@ func isDirective(line string) bool {
21 return strings.HasPrefix(line, "go:") || strings.HasPrefix(line, "line:")
22 }
23
24+// isURI returns true if the line contains an HTTP URI.
25+func isURI(line string) bool {
26+ return strings.Contains(line, "http://") || strings.Contains(line, "https://")
27+}
28+
29 var notes = []string{"TODO", "BUG", "FIXME", "OPTIMIZE"}
30
31 // isNote returns true if the unescaped comment is a note: TODO, BUG, FIXME, OPTIMIZE.