mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-06-10 21:01:41 +00:00
update
This commit is contained in:
37
node_modules/parseqs/index.js
generated
vendored
Normal file
37
node_modules/parseqs/index.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Compiles a querystring
|
||||
* Returns string representation of the object
|
||||
*
|
||||
* @param {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.encode = function (obj) {
|
||||
var str = '';
|
||||
|
||||
for (var i in obj) {
|
||||
if (obj.hasOwnProperty(i)) {
|
||||
if (str.length) str += '&';
|
||||
str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses a simple querystring into an object
|
||||
*
|
||||
* @param {String} qs
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.decode = function(qs){
|
||||
var qry = {};
|
||||
var pairs = qs.split('&');
|
||||
for (var i = 0, l = pairs.length; i < l; i++) {
|
||||
var pair = pairs[i].split('=');
|
||||
qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
|
||||
}
|
||||
return qry;
|
||||
};
|
Reference in New Issue
Block a user