mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-13 19:45:26 +00:00
Fix query param handling by
* not using a for-of loop on an iterator that is transpiled wrongly * not using URL.searchParams which is only supported by rather new browsers
This commit is contained in:
@@ -28,8 +28,12 @@ function select_route(url: URL): Target {
|
||||
const params = route.params(match);
|
||||
|
||||
const query: Record<string, string | true> = {};
|
||||
for (const [key, value] of url.searchParams) query[key] = value || true;
|
||||
|
||||
if (url.search.length > 0) {
|
||||
url.search.slice(1).split('&').forEach(searchParam => {
|
||||
const [, key, value] = /([^=]+)=(.*)/.exec(searchParam);
|
||||
query[key] = value || true;
|
||||
})
|
||||
}
|
||||
return { url, route, data: { params, query } };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user