updated npm modules
This commit is contained in:
38
node_modules/querystringify/index.js
generated
vendored
38
node_modules/querystringify/index.js
generated
vendored
@@ -7,11 +7,30 @@ var has = Object.prototype.hasOwnProperty
|
||||
* Decode a URI encoded string.
|
||||
*
|
||||
* @param {String} input The URI encoded string.
|
||||
* @returns {String} The decoded string.
|
||||
* @returns {String|Null} The decoded string.
|
||||
* @api private
|
||||
*/
|
||||
function decode(input) {
|
||||
return decodeURIComponent(input.replace(/\+/g, ' '));
|
||||
try {
|
||||
return decodeURIComponent(input.replace(/\+/g, ' '));
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to encode a given input.
|
||||
*
|
||||
* @param {String} input The string that needs to be encoded.
|
||||
* @returns {String|Null} The encoded string.
|
||||
* @api private
|
||||
*/
|
||||
function encode(input) {
|
||||
try {
|
||||
return encodeURIComponent(input);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,7 +54,10 @@ function querystring(query) {
|
||||
// methods like `toString` or __proto__ are not overriden by malicious
|
||||
// querystrings.
|
||||
//
|
||||
if (key in result) continue;
|
||||
// In the case if failed decoding, we want to omit the key/value pairs
|
||||
// from the result.
|
||||
//
|
||||
if (key === null || value === null || key in result) continue;
|
||||
result[key] = value;
|
||||
}
|
||||
|
||||
@@ -74,7 +96,15 @@ function querystringify(obj, prefix) {
|
||||
value = '';
|
||||
}
|
||||
|
||||
pairs.push(encodeURIComponent(key) +'='+ encodeURIComponent(value));
|
||||
key = encodeURIComponent(key);
|
||||
value = encodeURIComponent(value);
|
||||
|
||||
//
|
||||
// If we failed to encode the strings, we should bail out as we don't
|
||||
// want to add invalid strings to the query.
|
||||
//
|
||||
if (key === null || value === null) continue;
|
||||
pairs.push(key +'='+ value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user