Skip to content

Commit ad02f21

Browse files
authored
refactor(rewrite): reorganize referer rules and remove obsolete mapping
1 parent 46323b3 commit ad02f21

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

internal/reader/rewrite/referer_override_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ func TestGetRefererForURL(t *testing.T) {
3333
url: "https://scontent-sjc3-1.cdninstagram.com/example.jpg",
3434
expected: "https://www.instagram.com",
3535
},
36-
{
37-
name: "Piokok URL",
38-
url: "https://sp1.piokok.com/example.jpg",
39-
expected: "https://sp1.piokok.com",
40-
},
4136
{
4237
name: "Weibo Video URL",
4338
url: "https://f.video.weibocdn.com/example.mp4",

internal/reader/rewrite/rules.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,29 @@ func GetRefererForURL(u string) string {
5050
}
5151

5252
switch parsedUrl.Hostname() {
53-
case "moyu.im":
54-
return "https://i.jandan.net"
55-
case "i.pximg.net":
56-
return "https://www.pixiv.net"
57-
case "sp1.piokok.com":
58-
return "https://sp1.piokok.com"
53+
case "appinn.com":
54+
return "https://appinn.com"
55+
case "bjp.org.cn":
56+
return "https://bjp.org.cn"
5957
case "cdnfile.sspai.com":
6058
return "https://sspai.com"
6159
case "f.video.weibocdn.com":
6260
return "https://weibo.com"
61+
case "i.pximg.net":
62+
return "https://www.pixiv.net"
6363
case "img.hellogithub.com":
6464
return "https://hellogithub.com"
65-
case "bjp.org.cn":
66-
return "https://bjp.org.cn"
67-
case "appinn.com":
68-
return "https://appinn.com"
65+
case "moyu.im":
66+
return "https://i.jandan.net"
6967
}
7068

7169
switch {
72-
case strings.HasSuffix(parsedUrl.Hostname(), ".sinaimg.cn"):
73-
return "https://weibo.com"
7470
case strings.HasSuffix(parsedUrl.Hostname(), ".cdninstagram.com"):
7571
return "https://www.instagram.com"
7672
case strings.HasSuffix(parsedUrl.Hostname(), ".moyu.im"):
7773
return "https://i.jandan.net"
74+
case strings.HasSuffix(parsedUrl.Hostname(), ".sinaimg.cn"):
75+
return "https://weibo.com"
7876
}
7977

8078
return ""

0 commit comments

Comments
 (0)