Tweak link filtering when sending Webmention

master
Jan-Lukas Else 2020-01-12 18:13:18 +01:00
parent 1c3cc6480f
commit fb76567cef
1 changed files with 7 additions and 5 deletions

View File

@ -42,18 +42,20 @@ func SendWebmentions(url string) {
func filterLinks(links []string) []string { func filterLinks(links []string) []string {
var filteredLinks []string var filteredLinks []string
LINKFILTER:
for _, link := range links { for _, link := range links {
if strings.HasPrefix(link, BlogUrl) { if strings.HasPrefix(link, strings.TrimSuffix(BlogUrl, "/")) {
continue continue
} }
ignored := false
for _, ignoredURL := range IgnoredWebmentionUrls { for _, ignoredURL := range IgnoredWebmentionUrls {
if strings.HasPrefix(link, ignoredURL) { if !ignored && strings.HasPrefix(link, strings.TrimSuffix(ignoredURL, "/")) {
continue LINKFILTER ignored = true
} }
} }
if ignored != true {
filteredLinks = append(filteredLinks, link) filteredLinks = append(filteredLinks, link)
} }
}
return filteredLinks return filteredLinks
} }