前端代码
This commit is contained in:
34
node_modules/engine.io-client/build/esm/contrib/parseqs.js
generated
vendored
Normal file
34
node_modules/engine.io-client/build/esm/contrib/parseqs.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
// imported from https://github.com/galkn/querystring
|
||||
/**
|
||||
* Compiles a querystring
|
||||
* Returns string representation of the object
|
||||
*
|
||||
* @param {Object}
|
||||
* @api private
|
||||
*/
|
||||
export function encode(obj) {
|
||||
let str = '';
|
||||
for (let 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
|
||||
*/
|
||||
export function decode(qs) {
|
||||
let qry = {};
|
||||
let pairs = qs.split('&');
|
||||
for (let i = 0, l = pairs.length; i < l; i++) {
|
||||
let pair = pairs[i].split('=');
|
||||
qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
|
||||
}
|
||||
return qry;
|
||||
}
|
Reference in New Issue
Block a user