diff --git a/main.js b/main.js index 5e15af1..4b4658b 100644 --- a/main.js +++ b/main.js @@ -1255,7 +1255,14 @@ function createTab(initial, opts = {}) { return navigateTab(id, target + rest); } if (parsed.protocol === "bns:") return; - if (isBnsHost(parsed.hostname)) { e.preventDefault(); navigateTab(id, parsed.hostname + parsed.pathname); } + if (isBnsHost(parsed.hostname)) { + // Preserve query + fragment. Dropping them broke every search engine + // that submits via a classic form GET (Google's /search?q=foo lost + // the ?q=, so the results page opened blank). DuckDuckGo only + // appeared to work because its search is a client-side pushState. + e.preventDefault(); + navigateTab(id, u.replace(/^[a-z]+:\/\//i, "")); + } } catch {} }); // "You have unsaved changes" confirmation: fires when the page's beforeunload @@ -1381,13 +1388,18 @@ async function navigateTab(id, input) { const t = tabById(id); if (!t) return; let q = String(input).trim(); if (!q) return; - setLoading(t, true); // show the loading indicator immediately (covers BNS resolution) // Address bar doubles as a search box: anything that isn't a URL/hostname // (a bare word, or a phrase with spaces) becomes a web search. if (!looksLikeUrl(q)) q = SEARCH(q); const raw = q.replace(/^[a-z]+:\/\//i, ""); const host = raw.split("/")[0].toLowerCase(); const rest = raw.slice(host.length) || "/"; + // Reflect the target URL immediately so the address bar doesn't keep + // showing the previous page's URL for the whole load duration. Without + // this, emitTabs below (triggered by setLoading) carries the old t.url + // and the chrome renderer paints it, since we blurred the input on Enter. + t.url = "https://" + host + (rest === "/" ? "" : rest); + setLoading(t, true); // show the loading indicator immediately (covers BNS resolution) t.nav = (t.nav || 0) + 1; // Legacy "also on BCNR" chip state — kept clean; the passive switch is gone