mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
refactor(rewrite): reorganize referer rules and remove obsolete mapping
This commit is contained in:
parent
46323b3fe7
commit
ad02f21d04
2 changed files with 10 additions and 17 deletions
|
@ -33,11 +33,6 @@ func TestGetRefererForURL(t *testing.T) {
|
||||||
url: "https://scontent-sjc3-1.cdninstagram.com/example.jpg",
|
url: "https://scontent-sjc3-1.cdninstagram.com/example.jpg",
|
||||||
expected: "https://www.instagram.com",
|
expected: "https://www.instagram.com",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "Piokok URL",
|
|
||||||
url: "https://sp1.piokok.com/example.jpg",
|
|
||||||
expected: "https://sp1.piokok.com",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "Weibo Video URL",
|
name: "Weibo Video URL",
|
||||||
url: "https://f.video.weibocdn.com/example.mp4",
|
url: "https://f.video.weibocdn.com/example.mp4",
|
||||||
|
|
|
@ -50,31 +50,29 @@ func GetRefererForURL(u string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch parsedUrl.Hostname() {
|
switch parsedUrl.Hostname() {
|
||||||
case "moyu.im":
|
case "appinn.com":
|
||||||
return "https://i.jandan.net"
|
return "https://appinn.com"
|
||||||
case "i.pximg.net":
|
case "bjp.org.cn":
|
||||||
return "https://www.pixiv.net"
|
return "https://bjp.org.cn"
|
||||||
case "sp1.piokok.com":
|
|
||||||
return "https://sp1.piokok.com"
|
|
||||||
case "cdnfile.sspai.com":
|
case "cdnfile.sspai.com":
|
||||||
return "https://sspai.com"
|
return "https://sspai.com"
|
||||||
case "f.video.weibocdn.com":
|
case "f.video.weibocdn.com":
|
||||||
return "https://weibo.com"
|
return "https://weibo.com"
|
||||||
|
case "i.pximg.net":
|
||||||
|
return "https://www.pixiv.net"
|
||||||
case "img.hellogithub.com":
|
case "img.hellogithub.com":
|
||||||
return "https://hellogithub.com"
|
return "https://hellogithub.com"
|
||||||
case "bjp.org.cn":
|
case "moyu.im":
|
||||||
return "https://bjp.org.cn"
|
return "https://i.jandan.net"
|
||||||
case "appinn.com":
|
|
||||||
return "https://appinn.com"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case strings.HasSuffix(parsedUrl.Hostname(), ".sinaimg.cn"):
|
|
||||||
return "https://weibo.com"
|
|
||||||
case strings.HasSuffix(parsedUrl.Hostname(), ".cdninstagram.com"):
|
case strings.HasSuffix(parsedUrl.Hostname(), ".cdninstagram.com"):
|
||||||
return "https://www.instagram.com"
|
return "https://www.instagram.com"
|
||||||
case strings.HasSuffix(parsedUrl.Hostname(), ".moyu.im"):
|
case strings.HasSuffix(parsedUrl.Hostname(), ".moyu.im"):
|
||||||
return "https://i.jandan.net"
|
return "https://i.jandan.net"
|
||||||
|
case strings.HasSuffix(parsedUrl.Hostname(), ".sinaimg.cn"):
|
||||||
|
return "https://weibo.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue