From e991cde46f7d49bdd8af30f63a39a98b97f4aa52 Mon Sep 17 00:00:00 2001 From: Lia Lenckowski Date: Wed, 16 Aug 2023 20:26:13 +0200 Subject: don't appear in browser history when searching directly --- frontend/query.ts | 2 +- frontend/search.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/query.ts b/frontend/query.ts index 37f62f4..e8d41b1 100644 --- a/frontend/query.ts +++ b/frontend/query.ts @@ -34,7 +34,7 @@ export async function process_query(default_engine: string, query: string) { if (!url) return status("error", "Invalid search engine.") status("success", `Forwarding to ${url}`) - setTimeout(() => document.location.href = url!, 0) + document.location.replace(url) } async function search_url(engine: string, query: string) { diff --git a/frontend/search.ts b/frontend/search.ts index bca2fc0..40b7f91 100644 --- a/frontend/search.ts +++ b/frontend/search.ts @@ -24,11 +24,15 @@ export function section_search(engine: string) { const input = e("input", { type: "text" }) input.addEventListener("keydown", ev => { - if (ev.code == "Enter") process_query(engine, input.value ?? "") + if (ev.code == "Enter") { + history.pushState({}, "", window.location.href) + process_query(engine, input.value ?? "") + } }) const submit = e("button", {}, "Search") submit.addEventListener("click", () => { + history.pushState({}, "", window.location.href) process_query(engine, input.value ?? "") }) -- cgit v1.2.3-70-g09d2