simple2k13
Version:
some simple functions
21 lines • 620 B
JavaScript
/** @format */
function queryToObject(search) {
search = search || location.search;
const result = {};
if (typeof URLSearchParams === "function") {
const searchEntries = new URLSearchParams(search);
for (const [key, value] of searchEntries) {
result[key] = value;
}
}
else {
const paramLists = search.replace("?", "").split("&");
for (const param of paramLists) {
const [key, value] = param.split("=");
result[key] = value;
}
}
return result;
}
export default queryToObject;
//# sourceMappingURL=index.js.map