Tweak link filtering when sending Webmention
parent
1c3cc6480f
commit
fb76567cef
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue