Initial boiler plate project
This commit is contained in:
73
node_modules/next/dist/shared/lib/router/utils/querystring.js
generated
vendored
Normal file
73
node_modules/next/dist/shared/lib/router/utils/querystring.js
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
assign: null,
|
||||
searchParamsToUrlQuery: null,
|
||||
urlQueryToSearchParams: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
assign: function() {
|
||||
return assign;
|
||||
},
|
||||
searchParamsToUrlQuery: function() {
|
||||
return searchParamsToUrlQuery;
|
||||
},
|
||||
urlQueryToSearchParams: function() {
|
||||
return urlQueryToSearchParams;
|
||||
}
|
||||
});
|
||||
function searchParamsToUrlQuery(searchParams) {
|
||||
const query = {};
|
||||
searchParams.forEach((value, key)=>{
|
||||
if (typeof query[key] === "undefined") {
|
||||
query[key] = value;
|
||||
} else if (Array.isArray(query[key])) {
|
||||
query[key].push(value);
|
||||
} else {
|
||||
query[key] = [
|
||||
query[key],
|
||||
value
|
||||
];
|
||||
}
|
||||
});
|
||||
return query;
|
||||
}
|
||||
function stringifyUrlQueryParam(param) {
|
||||
if (typeof param === "string" || typeof param === "number" && !isNaN(param) || typeof param === "boolean") {
|
||||
return String(param);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
function urlQueryToSearchParams(urlQuery) {
|
||||
const result = new URLSearchParams();
|
||||
Object.entries(urlQuery).forEach((param)=>{
|
||||
let [key, value] = param;
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach((item)=>result.append(key, stringifyUrlQueryParam(item)));
|
||||
} else {
|
||||
result.set(key, stringifyUrlQueryParam(value));
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
function assign(target) {
|
||||
for(var _len = arguments.length, searchParamsList = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
||||
searchParamsList[_key - 1] = arguments[_key];
|
||||
}
|
||||
searchParamsList.forEach((searchParams)=>{
|
||||
Array.from(searchParams.keys()).forEach((key)=>target.delete(key));
|
||||
searchParams.forEach((value, key)=>target.append(key, value));
|
||||
});
|
||||
return target;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=querystring.js.map
|
||||
Reference in New Issue
Block a user