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:
Lukas Taegert
2018-01-26 23:29:34 +01:00
parent 7a3506420f
commit 297f4276de
2 changed files with 26 additions and 3 deletions

View File

@@ -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 } };
}
}