Beispiel #1
0
func ExampleNormalizeURLString() {
	if normalized, err := purell.NormalizeURLString("hTTp://someWEBsite.com:80/Amazing%3f/url/",
		purell.LowercaseScheme|purell.LowercaseHost|purell.UppercaseEscapes); err != nil {
		panic(err)
	} else {
		fmt.Print(normalized)
	}
	// Output: http://somewebsite.com:80/Amazing%3F/url/
}
Beispiel #2
0
func TestNormalize(t *testing.T) {
	for _, test := range tests {
		got, err := purell.NormalizeURLString(test.url, test.flags)
		if err != nil {
			t.Errorf("got error on %q: %v", test.url, err)
		} else if got != test.expect {
			t.Errorf("normalizing url %q, flags %v: expected %q; got %q", test.url, test.flags, test.expect, got)
		}
	}
}