sindresorhus/normalize-url

partially decoded special chars in query params

Closed this issue · 7 comments

'https://example.com?tint=%23505050,%23505050' is normalised to 'https://example.com/?tint=%23505050,#505050'. Note that only one of the entities is decoded. I'm not even sure that the entities should be decoded here - what's the justification for that?

Would you mind adding a failing test?

Gladly. But could you explain what you'd prefer to see? Both %23s transformed to #, or neither?

It should decode both.

Relevant:

t.is(m('sindresorhus.com/?foo=bar%20baz'), 'http://sindresorhus.com/?foo=bar baz');

Uh-oh:

$ node
> url = {search:'foo=#505050,#505050'}
{ search: 'foo=#505050,#505050' }
> require('url').format(url)
'?foo=%23505050,#505050'

Do you think this is a Node bug? Seems to affect Node 4, 5 and 6.

Yes, looks like a Node.js bug. Can you open an issue over at the Node.js issue tracker and paste a link to it here?

Looks like it's fixed! Using v4.7.0:

$ node
> url = {search:'foo=#505050,#505050'}
{ search: 'foo=#505050,#505050' }
> require('url').format(url)
'?foo=%23505050,%23505050'