From 9ef4f33e3853d25a3627703a987fc73605e787df Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 3 Sep 2018 20:09:25 -0400 Subject: [PATCH] decode query params --- src/runtime/index.ts | 2 +- test/app/routes/echo/page/[slug].html | 7 ++++--- test/app/routes/index.html | 2 +- test/common/test.js | 12 ++++++------ 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/runtime/index.ts b/src/runtime/index.ts index 83c0a76..9530604 100644 --- a/src/runtime/index.ts +++ b/src/runtime/index.ts @@ -67,7 +67,7 @@ function select_route(url: URL): Target { if (url.search.length > 0) { url.search.slice(1).split('&').forEach(searchParam => { const [, key, value] = /([^=]+)=(.*)/.exec(searchParam); - query[key] = value || true; + query[key] = value ? decodeURIComponent(value.replace(/\+/g, ' ')) : true; }); } return { url, path, page, match, query }; diff --git a/test/app/routes/echo/page/[slug].html b/test/app/routes/echo/page/[slug].html index f393c6a..7b2f0a8 100644 --- a/test/app/routes/echo/page/[slug].html +++ b/test/app/routes/echo/page/[slug].html @@ -1,10 +1,11 @@ -

{slug}

+

{slug} ({message})