Skip to content

Commit 2a1f38c

Browse files
committed
Improve regex pattern
1 parent 8a8927f commit 2a1f38c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

pkg/http.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,10 @@ func (wbrc *Archiver) fetch(url string, ch chan<- string) {
8484
}
8585

8686
func isURL(str string) bool {
87-
re := regexp.MustCompile(`(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,255}\.[a-z]{0,63}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)`)
87+
re := regexp.MustCompile(`https?://?[-a-zA-Z0-9@:%._\+~#=]{1,255}\.[a-z]{0,63}\b(?:[-a-zA-Z0-9@:%_\+.~#?&//=]*)`)
8888
match := re.FindAllString(str, -1)
89-
for _, el := range match {
90-
if len(el) > 2 {
91-
return true
92-
}
93-
}
94-
return false
89+
90+
return len(match) >= 1
9591
}
9692

9793
func latest(s string) string {

0 commit comments

Comments
 (0)