aboutsummaryrefslogtreecommitdiff
path: root/archive.go
diff options
context:
space:
mode:
authorJordan <me@jordan.im>2021-12-07 11:07:13 -0700
committerJordan <me@jordan.im>2021-12-07 11:07:13 -0700
commite4e052cf2709835217a748db7674bb6b45d0a8cf (patch)
treee82c5886b04a532c155f4225ab167b40c6b72380 /archive.go
parent1bb7d04b6f090044a31638bd2adbeac004567c4b (diff)
downloadkeep-e4e052cf2709835217a748db7674bb6b45d0a8cf.tar.gz
keep-e4e052cf2709835217a748db7674bb6b45d0a8cf.zip
archive, keep: host -> regexp ignore list
Diffstat (limited to 'archive.go')
-rw-r--r--archive.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/archive.go b/archive.go
index 7f44078..924e6f4 100644
--- a/archive.go
+++ b/archive.go
@@ -4,6 +4,7 @@ import (
"encoding/json"
"log"
"net/http"
+ "regexp"
"strconv"
"time"
)
@@ -14,11 +15,6 @@ var (
TIMEOUT time.Duration = 25
client *http.Client = &http.Client{Timeout: TIMEOUT * time.Second}
-
- ignoreList = []string{"cdn.discordapp.com", "discord.com", "tenor.com",
- "c.tenor.com", "archive.org", "web.archive.org", "youtu.be",
- "youtube.com", "www.youtube.com", "discord.gg", "media.discordapp.net",
- "open.spotify.com", "i.redd.it", "v.redd.it"}
)
type Wayback struct {
@@ -34,11 +30,11 @@ type Closest struct {
Status string `json:"status"`
}
-func isIgnored(host string) bool {
+func isIgnored(regex []string, url string) bool {
- for _, h := range ignoreList {
+ for _, r := range regex {
- if host == h {
+ if v := regexp.MustCompile(r); v.MatchString(url) {
return true
}
}