class querystring {
static parse(str, sep = "&", eq = "=") {
let res = {};
let arr = str.split(sep);
arr.map(function (item, index) {
if(res[item.split(eq)[0]]){
res[item.split(eq)[0]]=[res[item.split(eq)[0]]];
res[item.split(eq)[0]].push(item.split(eq)[1]);
}else{
res[item.split(eq)[0]]=item.split(eq)[1];
}
});
return res;
}
static stringify(obj,sep="&",eq="="){
let res="";
for(let key in obj){
if(typeof obj[key]==='object'){
res+=key+'='+obj[key].join('&'+key+'=');
}else{
res+=key+'='+obj[key];
}
res+='&';
}
res=res.substr(0,res.length-1);
return res;
}
}
export default querystring;