fix: update regex to handle non-alphanumeric chars

This commit is contained in:
Samyak Bardiya 2025-02-15 18:33:21 +05:30
parent 3165c3dccb
commit 001e48129b
No known key found for this signature in database
GPG Key ID: 5A3E3C8C7C08CDCD

View File

@ -55,13 +55,13 @@ function getBangredirectUrl() {
return null; return null;
} }
const match = query.match(/!([a-z0-9]+)/i); const match = query.match(/!(\S+)/i);
const bangCandidate = match?.[1]?.toLowerCase(); const bangCandidate = match?.[1]?.toLowerCase();
const selectedBang = bangs.find((b) => b.t === bangCandidate) ?? defaultBang; const selectedBang = bangs.find((b) => b.t === bangCandidate) ?? defaultBang;
// Remove the first bang from the query // 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: // Format of the url is:
// https://www.google.com/search?q={{{s}}} // https://www.google.com/search?q={{{s}}}