From 4151338500d8f973ca83fd5ef48f565ed5ed244f Mon Sep 17 00:00:00 2001 From: f Date: Fri, 17 Sep 2021 15:38:56 -0300 Subject: [PATCH] =?UTF-8?q?Codificar=20correctamente=20los=20par=C3=A1metr?= =?UTF-8?q?os=20de=20b=C3=BAsqueda?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _packs/controllers/search_controller.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/_packs/controllers/search_controller.js b/_packs/controllers/search_controller.js index 59305a5..b1f8bea 100644 --- a/_packs/controllers/search_controller.js +++ b/_packs/controllers/search_controller.js @@ -16,10 +16,10 @@ export default class extends Controller { } connect () { - const q = window.location.search.match(/^\?q=(?.*)&?/) + const q = new URLSearchParams(window.location.search).get('q').trim() if (q) { - this.qTarget.value = decodeURI(q.groups.q) + this.qTarget.value = q this.search() } } @@ -52,8 +52,9 @@ export default class extends Controller { const template = await request.text() const html = await this.engine.parseAndRender(template, { q, site, results }) const title = `${site.i18n.search.title} - ${q}` + const query = new URLSearchParams({ q }) - window.history.pushState({ q }, title, `?q=${encodeURI(q)}`) + window.history.pushState({ q }, title, `?${query.toString()}`) document.title = title main.innerHTML = html