forked from bluesky-social/indigo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurl_test.go
33 lines (28 loc) · 1.18 KB
/
url_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package search
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNormalizeLossyURL(t *testing.T) {
assert := assert.New(t)
fixtures := []struct {
orig string
clean string
}{
{orig: "", clean: ""},
{orig: "asdf", clean: "asdf"},
{orig: "HTTP://bSky.app:80/index.html", clean: "http://bsky.app"},
{orig: "https://example.com/thing?c=123&utm_campaign=blah&a=first", clean: "https://example.com/thing?a=first&c=123"},
{orig: "https://example.com/thing?c=123&utm_campaign=blah&a=first", clean: "https://example.com/thing?a=first&c=123"},
{orig: "http://example.com/foo//bar.html", clean: "http://example.com/foo/bar.html"},
{orig: "http://example.com/bar.html#section1", clean: "http://example.com/bar.html"},
{orig: "http://example.com/foo/", clean: "http://example.com/foo"},
{orig: "http://example.com/", clean: "http://example.com"},
{orig: "http://example.com/%7Efoo", clean: "http://example.com/~foo"},
{orig: "http://example.com/foo/./bar/baz/../qux", clean: "http://example.com/foo/bar/qux"},
{orig: "http://www.example.com/", clean: "http://example.com"},
}
for _, fix := range fixtures {
assert.Equal(fix.clean, NormalizeLossyURL(fix.orig))
}
}