refine url normalization
Before, the entire url was being lowercased, which mutilates various case-sensitive parts. Now, only the host gets lowercased, and the test verify that the userinfo, path, and query parts preserve their original case.
This commit is contained in:
@@ -142,6 +142,22 @@ func TestNormalizeURL(t *testing.T) {
|
||||
input: "wss://relay.example.com/nostr",
|
||||
expected: "wss://relay.example.com/nostr",
|
||||
},
|
||||
{
|
||||
name: "lowercase scheme+host, preserve path case",
|
||||
input: "Wss://Relay.Example.Com/Nostr",
|
||||
expected: "wss://relay.example.com/Nostr",
|
||||
},
|
||||
{
|
||||
name: "preserve user info",
|
||||
input: "wss://user:P@ssWord@relay.example.com",
|
||||
// String() cannot output a raw `@` so `%40` is expected
|
||||
expected: "wss://user:P%40ssWord@relay.example.com",
|
||||
},
|
||||
{
|
||||
name: "preserve query",
|
||||
input: "Wss://relay.example.com?field=Value",
|
||||
expected: "wss://relay.example.com?field=Value",
|
||||
},
|
||||
{
|
||||
name: "no change needed",
|
||||
input: "wss://relay.example.com",
|
||||
|
||||
Reference in New Issue
Block a user