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