sindresorhus/normalize-url

Equal sign is added to end of empty query string variable

Closed this issue · 6 comments

> normalize_url('example.com/?a');
http://example.com/?a=

> (new URL('http://example.com/?a')).toString()
http://example.com/?a

That looks like a bug, yes.

It seems urlObj.searchParams.sort(); is doing this. I will look into it if I can find a simple fix.

So it seems this is by design according to the spec:

I created an issue anyway to discuss if this could be made optional if it makes sense so please add your use case @mustafa0x.

See how the original Wiki (wiki.c2.com) links to pages:

So they seemed to be clear enough in the referenced issues at whatwg. This is the spec and therefore I wouldn't implement any transformation in normalize-url since it should normalize it TO the spec. What do you think @sindresorhus ?

Thanks for the research @muuvmuuv.

FWIW, this affects my web app since adding = causes a cache-miss.