Equal sign is added to end of empty query string variable
Closed this issue · 6 comments
mustafa0x commented
> normalize_url('example.com/?a');
http://example.com/?a=
> (new URL('http://example.com/?a')).toString()
http://example.com/?a
sindresorhus commented
That looks like a bug, yes.
muuvmuuv commented
It seems urlObj.searchParams.sort();
is doing this. I will look into it if I can find a simple fix.
muuvmuuv commented
So it seems this is by design according to the spec:
- https://url.spec.whatwg.org/#dom-urlsearchparams-sort
- https://url.spec.whatwg.org/#concept-urlencoded-serializer
I created an issue anyway to discuss if this could be made optional if it makes sense so please add your use case @mustafa0x.
mustafa0x commented
See how the original Wiki (wiki.c2.com) links to pages:
muuvmuuv commented
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 ?