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