Open Mickael-van-der-Beek opened 9 years ago
Some notes:
@petkaantonov : I'm using querystringparser
as a drop-in replacement for qs
inside fast-url-parser
, like this:
var querystringParser = require('querystringparser');
var fastUrlParser = require('fast-url-parser');
fastUrlParser.replace();
url.parse('http://www.google.com/hello?=test', true)
I understand the part about using a try {} catch {}
block but since fast-url-parser
is supposed to be used as a drop-in replacement of the core url
module I found it a little weird.
The same code without querystringparser
, so with qs
will be something like this:
var fastUrlParser = require('fast-url-parser');
fastUrlParser.replace();
url.parse('http://www.google.com/hello?=test', true);
and return the following object:
{ _protocol: 'http',
_href: '',
_port: -1,
_query: { '': 'test' },
auth: null,
slashes: true,
host: 'www.google.com',
hostname: 'www.google.com',
hash: null,
search: '?=test',
pathname: '/hello',
_prependSlash: false }
querystringparser is not compatible with querystring but fast url parser is compatible with url
@petkaantonov If querystringparser
is compatible with qs
and fast-url-parser
with url
. Wouldn't that make it necessary for querystringparser
to be compatible with querystring
at least in the context of a drop-in replacement of url
?
@Mickael-van-der-Beek qs
is not compatible with nodes url
:)
On another note I hit this same exception when passing { '': '' }
as argument (result of a malformed request).
Could there be exposed an Error class (for use as predicate) for operational errors? I'm not sure this one should happen though, as I guess there is no such thing as a "valid" query. Maybe it should always just do a best effort?
The library crashes when a querystring contains a value without a key or an empty key.
e.g:
will crash with the error:
In comparison Node.js (v0.10.29 for me), will return:
and considers that the key is an empty string
''
.