commit 001e48129b730959b3e841d94bda86e9bc028795
parent 3165c3dccb24f90afc3bcca6b476387a3a87c3a7
Author: Samyak Bardiya <mail@samyakbardiya.dev>
Date: Sat, 15 Feb 2025 18:33:21 +0530
fix: update regex to handle non-alphanumeric chars
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main.ts b/src/main.ts
@@ -55,13 +55,13 @@ function getBangredirectUrl() {
return null;
}
- const match = query.match(/!([a-z0-9]+)/i);
+ const match = query.match(/!(\S+)/i);
const bangCandidate = match?.[1]?.toLowerCase();
const selectedBang = bangs.find((b) => b.t === bangCandidate) ?? defaultBang;
// Remove the first bang from the query
- const cleanQuery = query.replace(/![a-z0-9]+\s*/i, "").trim();
+ const cleanQuery = query.replace(/!\S+\s*/i, "").trim();
// Format of the url is:
// https://www.google.com/search?q={{{s}}}