Skip to content

Commit

Permalink
Match full URLs against include/exclude regexps (#235)
Browse files Browse the repository at this point in the history
Fixes #211

Co-authored-by: Yota Toyama <raviqqe@gmail.com>
  • Loading branch information
lpar and raviqqe committed Aug 1, 2022
1 parent b21aa16 commit ff097ab
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions link_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,19 @@ func (f linkFinder) Find(n *html.Node, base *url.URL) map[string]error {
for _, s := range ss {
s := strings.TrimSpace(s)

if s == "" || f.isLinkExcluded(s) || len(f.includedPatterns) > 0 && !f.isLinkIncluded(s) {
continue
}

u, err := url.Parse(s)
if err != nil {
ls[s] = err
} else if _, ok := validSchemes[u.Scheme]; ok {
ls[base.ResolveReference(u).String()] = nil
continue
}
fullurl := base.ResolveReference(u).String()

if s == "" || f.isLinkExcluded(fullurl) || len(f.includedPatterns) > 0 && !f.isLinkIncluded(fullurl) {
continue
}

if _, ok := validSchemes[u.Scheme]; ok {
ls[fullurl] = nil
}
}
}
Expand Down

0 comments on commit ff097ab

Please sign in to comment.