From bdcd8fa39bc697d5ab2f10c6d600a78bfcbfdf34 Mon Sep 17 00:00:00 2001 From: Lia Lenckowski Date: Fri, 28 Jul 2023 23:47:58 +0200 Subject: case-insensitive engine selection --- frontend/main.ts | 2 +- frontend/query.ts | 2 +- frontend/ui.ts | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'frontend') diff --git a/frontend/main.ts b/frontend/main.ts index 85de64e..e14ccac 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -20,7 +20,7 @@ function process_url() { bangs.then(bangs => { console.log("bop"); - if (!bangs[engine]) { + if (!bangs[engine.toLowerCase()]) { status("error", "Engine does not exist") window.location.hash = "#" } diff --git a/frontend/query.ts b/frontend/query.ts index a608c57..7fa83e3 100644 --- a/frontend/query.ts +++ b/frontend/query.ts @@ -39,5 +39,5 @@ export async function process_query(default_engine: string, query: string) { } async function search_url(engine: string, query: string) { - return (await bangs)[engine]?.url.replace("{{{s}}}", encodeURIComponent(query).replaceAll("%20", "+")) + return (await bangs)[engine.toLowerCase()]?.url.replace("{{{s}}}", encodeURIComponent(query).replaceAll("%20", "+")) } diff --git a/frontend/ui.ts b/frontend/ui.ts index 22f9d71..8ce34a4 100644 --- a/frontend/ui.ts +++ b/frontend/ui.ts @@ -11,6 +11,7 @@ export function add_page_content(engine?: string) { } function section_search(engine: string) { + engine = engine.toLowerCase(); const section = document.createElement("section") section.classList.add("search") @@ -55,7 +56,8 @@ function section_engine_select() { section.classList.add("engine-select") const select = async (e: string) => { - if (!(await bangs)[e]) return status("error", `Engine ${JSON.stringify(e)} does not exist.`) + const engine = e.toLowerCase(); + if (!(await bangs)[engine]) return status("error", `Engine ${JSON.stringify(e)} does not exist.`) window.location.hash = `#${e}` } -- cgit v1.2.3-70-g09d2