···
6
+
"github.com/stretchr/testify/assert"
9
+
func TestNormalizeURL(t *testing.T) {
16
+
name: "protocol-relative URL",
17
+
input: "//cdn.example.com/image.jpg",
18
+
expected: "https://cdn.example.com/image.jpg",
21
+
name: "https URL unchanged",
22
+
input: "https://example.com/image.jpg",
23
+
expected: "https://example.com/image.jpg",
26
+
name: "http URL unchanged",
27
+
input: "http://example.com/image.jpg",
28
+
expected: "http://example.com/image.jpg",
31
+
name: "empty string",
36
+
name: "protocol-relative with query params",
37
+
input: "//cdn.example.com/image.jpg?width=500&height=300",
38
+
expected: "https://cdn.example.com/image.jpg?width=500&height=300",
41
+
name: "real Streamable URL",
42
+
input: "//cdn-cf-east.streamable.com/image/7kpdft.jpg?Expires=1762932720",
43
+
expected: "https://cdn-cf-east.streamable.com/image/7kpdft.jpg?Expires=1762932720",
47
+
for _, tt := range tests {
48
+
t.Run(tt.name, func(t *testing.T) {
49
+
result := normalizeURL(tt.input)
50
+
assert.Equal(t, tt.expected, result)