Documentation states that `querystring.unescape` may be overridden to
replace unescaper during parsing. However, the function was only
being used as a fallback for when the native decoder throws (on a
malformed URL). This patch moves the call to the native function and
the try/catch around it into querystring.unescape then has the parser
always invoke it, so that an override will always be used.
Fixes #4055
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Currently, stringification of an empty array outputs a single
separator character. This commit causes an empty array to output
the empty string.
Signed-off-by: Fedor Indutny <fedor@indutny.com>
Not all querystring are utf-8 encoding, make querystring can be used
to encode / decode `non-utf8` encoding string if necessary.
Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
QueryString.stringify() allowed a fourth argument that was used as a
conditional in the return value, but was undocumented, not used by core
and always was always false/undefiend. So the argument and conditional
have been removed.
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
If hasOwnProperty is overridden, then calling `obj.hasOwnProperty(prop)`
can fail. Any time a dictionary of user-generated items is built, we
cannot rely on hasOwnProperty being safe, so must call it from the
Object.prototype explicitly.
- Handle only the most basic of query string parsing and construction.
Leave the rest (e.g. Rails/PHP behaviors) to modules higher up the
stack, like Express.
Also, make a slight change from original on url-module to put the
spacePattern into the function. On closer inspection, it turns out that the
nonlocal-var cost is higher than the compiling-a-regexp cost.
Also, documentation.