aboutsummaryrefslogtreecommitdiff
path: root/src/main.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.ts')
-rw-r--r--src/main.ts8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main.ts b/src/main.ts
index 7b81419..4452a6f 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -6,7 +6,7 @@ function noSearchDefaultPageRender() {
app.innerHTML = `
<div style="display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh;">
<div class="content-container">
- <h1>Unduck</h1>
+ <h1>Und*ck</h1>
<p>DuckDuckGo's bang redirects are too slow. Add the following URL as a custom search engine to your browser. Enables <a href="https://duckduckgo.com/bang.html" target="_blank">all of DuckDuckGo's bangs.</a></p>
<div class="url-container">
<input
@@ -63,12 +63,16 @@ function getBangredirectUrl() {
// Remove the first bang from the query
const cleanQuery = query.replace(/!\S+\s*/i, "").trim();
+ // If the query is just `!gh`, use `github.com` instead of `github.com/search?q=`
+ if (cleanQuery === "")
+ return selectedBang ? `https://${selectedBang.d}` : null;
+
// Format of the url is:
// https://www.google.com/search?q={{{s}}}
const searchUrl = selectedBang?.u.replace(
"{{{s}}}",
// Replace %2F with / to fix formats like "!ghr+t3dotgg/unduck"
- encodeURIComponent(cleanQuery).replace(/%2F/g, "/")
+ encodeURIComponent(cleanQuery).replace(/%2F/g, "/"),
);
if (!searchUrl) return null;