mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-16 04:44:35 +00:00
Fix for #618
`query-string` is used as example see https://github.com/sindresorhus/query-string/blob/master/index.js#L186
This commit is contained in:
committed by
GitHub
parent
7be7e1eb9f
commit
06eee32ee5
@@ -97,8 +97,7 @@ export function select_target(url: URL): Target {
|
|||||||
const query: Record<string, string | string[]> = Object.create(null);
|
const query: Record<string, string | string[]> = Object.create(null);
|
||||||
if (url.search.length > 0) {
|
if (url.search.length > 0) {
|
||||||
url.search.slice(1).split('&').forEach(searchParam => {
|
url.search.slice(1).split('&').forEach(searchParam => {
|
||||||
let [, key, value] = /([^=]*)(?:=(.*))?/.exec(decodeURIComponent(searchParam));
|
let [, key, value = ''] = /([^=]*)(?:=(.*))?/.exec(decodeURIComponent(searchParam.replace(/\+/g, ' ')));
|
||||||
value = (value || '').replace(/\+/g, ' ');
|
|
||||||
if (typeof query[key] === 'string') query[key] = [<string>query[key]];
|
if (typeof query[key] === 'string') query[key] = [<string>query[key]];
|
||||||
if (typeof query[key] === 'object') (query[key] as string[]).push(value);
|
if (typeof query[key] === 'object') (query[key] as string[]).push(value);
|
||||||
else query[key] = value;
|
else query[key] = value;
|
||||||
|
|||||||
Reference in New Issue
Block a user