Skip to content

Commit

Permalink
Improve regex pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
web-flow committed Jan 11, 2021
1 parent 8a8927f commit 2a1f38c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pkg/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,10 @@ func (wbrc *Archiver) fetch(url string, ch chan<- string) {
}

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

return len(match) >= 1
}

func latest(s string) string {
Expand Down

0 comments on commit 2a1f38c

Please sign in to comment.