Browse Source

test(rewrite): add additional test cases for `GetRefererForURL`

Frédéric Guillot 3 months ago
parent
commit
6106546a32
1 changed files with 15 additions and 0 deletions
  1. 15 0
      internal/reader/rewrite/referer_override_test.go

+ 15 - 0
internal/reader/rewrite/referer_override_test.go

@@ -53,6 +53,21 @@ func TestGetRefererForURL(t *testing.T) {
 			url:      "https://example.com/image.jpg",
 			expected: "",
 		},
+		{
+			name:     "Exact hostname match",
+			url:      "https://appinn.com/some/path",
+			expected: "https://appinn.com",
+		},
+		{
+			name:     "Only hostnames starting with a dot should match as suffix",
+			url:      "https://fake-appinn.com/some/path",
+			expected: "",
+		},
+		{
+			name:     "Subdomain match with suffix",
+			url:      "https://sub.moyu.im/image.png",
+			expected: "https://i.jandan.net",
+		},
 	}
 
 	for _, tc := range testCases {