Merge pull request #5 from samyakbardiya/fix/handle-non-alphanumeric-chars

fix: Handle non-alphanumeric characters in bangs
This commit is contained in:
Theo Browne 2025-02-15 18:16:14 -08:00 committed by GitHub
commit f96ce5706d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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}}}