Node: searchParams empty value not keyed

Created on 21 Dec 2016  路  12Comments  路  Source: nodejs/node

const url = new URL("http://domain/?va r1=++dir&var2=text&var3");

console.log( Array.from(url.searchParams.keys()) );
//-> ["va r1", "var2"]

Using Firefox's native URL, the same logs:

["va r1", "var2", "var3"]
url whatwg-url

All 12 comments

@TimothyGu @jasnell

+1... this is a current limitation caused by the use of the existing querystring module to implement the searchParams bit. I'll likely be reworking this entire part of the implementation in the not too distant future to be more spec compliant.

Are you sure this isn鈥檛 fixed on master already? The above example seems to work for me.

it could be given the recent work that was done. I haven't had the chance to test it fully.

I have a local branch that implements the entire URLSearchParams parsing and serialization in C++, which will fix this problem assuming it is not fixed on master. I will hopefully find some time soon to submit it.

Working for me with v7.3.0 and beca3244e2792bc4257f480b138c1b603de3781c on master (macOS Sierra). @stevenvachon what version of node/platform are you using?

I tested with:

const URL = require('url').URL;

const url = new URL("http://domain/?va r1=++dir&var2=text&var3");
console.log( Array.from(url.searchParams.keys()) );

@addaleax @gibfahn define "works". Does an array with a length of 3 get logged?

Using v7.3.0 and macOS Sierra.

Working for me too, (using master)

@stevenvachon It means that the output is [ 'va r1', 'var2', 'var3' ], i.e. exactly what Firefox is returning too

Looked into this again and reinstalled v7.3.0. Now, it is logging fine here. When I'd closed this, I'd thought that those claiming it was working fine were using an unreleased Node version. Apparently they were using these same version. I'm not sure what was happening earlier.

@stevenvachon, 7.3.0 was released _after_ those comments so that is probably why

It was released just before, as I'd just downloaded and installed it.

I may have been working with one test case and accidentally copied from another without noticing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stevenvachon picture stevenvachon  路  3Comments

willnwhite picture willnwhite  路  3Comments

cong88 picture cong88  路  3Comments

akdor1154 picture akdor1154  路  3Comments

danielstaleiny picture danielstaleiny  路  3Comments