From 673379eb11f7986f0cfc178987e80db430683a46 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 11:05:15 +0000 Subject: [PATCH 1/3] Initial plan From dc71c65a0239411bdaf743d5765533c1f2028aff Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 11:10:00 +0000 Subject: [PATCH 2/3] Fix upper search bar functionality and scramjet URL decoding - Enable upper search bar to work from any page including settings - Fix scramjet URL decoding to use proper $scramjet.url.href - Update both UpperSearchBar and index page for consistent behavior Co-authored-by: sriail <225764385+sriail@users.noreply.github.com> --- src/components/UpperSearchBar.astro | 27 +++++++++++++++++++++------ src/pages/index.astro | 7 +++---- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/components/UpperSearchBar.astro b/src/components/UpperSearchBar.astro index 1c2da7c..190abed 100644 --- a/src/components/UpperSearchBar.astro +++ b/src/components/UpperSearchBar.astro @@ -72,10 +72,8 @@ import { Icon } from "astro-icon/components"; if (iframeWin.__uv) { pageURL = iframeWin.__uv.location.href; } else if (iframeWin.$scramjet?.config?.prefix) { - const scramjetURL = iframeWin.location.href; - pageURL = scramjetURL - .replace(iframeWin.location.origin, '') - .replace(iframeWin.$scramjet.config.prefix, ''); + // Use scramjet's URL property which contains the decoded URL + pageURL = iframeWin.$scramjet.url.href; } else { pageURL = iframeWin.location.href; } @@ -99,8 +97,21 @@ import { Icon } from "astro-icon/components"; } } } else if (iframeSrc.includes('/~/scramjet/')) { + // Extract and decode Scramjet URL const encoded = iframeSrc.split('/~/scramjet/')[1]; - upperSearchInput.value = encoded || iframeSrc; + if (encoded && typeof $scramjetLoadController !== 'undefined') { + try { + const { ScramjetController } = $scramjetLoadController(); + // Create a temporary controller instance to decode + const tempController = new ScramjetController({ prefix: '/~/scramjet/' }); + const decoded = tempController.decodeUrl(encoded); + upperSearchInput.value = decoded; + } catch { + upperSearchInput.value = encoded; + } + } else { + upperSearchInput.value = encoded || iframeSrc; + } } else { upperSearchInput.value = iframeSrc; } @@ -121,13 +132,17 @@ import { Icon } from "astro-icon/components"; return; } - // Regular URL handling - only if iframe exists + // Regular URL handling + // If we're on the main page with iframe, use it if (iframe && bhl && phl) { iframe.classList.remove("hidden"); await sw.ready(); iframe.src = sw.encodeURL(inputValue); bhl.classList.add("hidden"); phl.classList.remove("hidden"); + } else { + // Otherwise, navigate to home page with the search query + window.location.href = '/?redir=' + btoa(inputValue); } } }); diff --git a/src/pages/index.astro b/src/pages/index.astro index 6d2a5df..2467458 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -94,10 +94,9 @@ const link = Astro.url.searchParams.get("redir"); if (iframeWin!.__uv) { return iframeWin!.__uv.location.href } - else if (iframeWin!.$scramjet?.config?.prefix) { - return iframeWin!.location.href - .replace(iframeWin!.location.origin, '') - .replace(iframeWin!.$scramjet.config.prefix, '') + else if (iframeWin!.$scramjet?.url) { + // Use scramjet's URL property which contains the decoded URL + return iframeWin!.$scramjet.url.href } else { // Fallback if neither proxy is available From bca456d574f4ebe6f4cd5aaeb29235e510226219 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 11:14:33 +0000 Subject: [PATCH 3/3] Improve URL decoding to handle cases when proxy objects not initialized - Fix URL display to properly decode from iframe src when proxy objects unavailable - Ensure consistent URL decoding for both UV and Scramjet proxies - Tested with both proxies successfully Co-authored-by: sriail <225764385+sriail@users.noreply.github.com> --- src/components/UpperSearchBar.astro | 78 +++++++++++++++-------------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/src/components/UpperSearchBar.astro b/src/components/UpperSearchBar.astro index 190abed..087cee5 100644 --- a/src/components/UpperSearchBar.astro +++ b/src/components/UpperSearchBar.astro @@ -71,54 +71,58 @@ import { Icon } from "astro-icon/components"; // Get the actual URL from the proxy if (iframeWin.__uv) { pageURL = iframeWin.__uv.location.href; - } else if (iframeWin.$scramjet?.config?.prefix) { + upperSearchInput.value = pageURL; + return; + } else if (iframeWin.$scramjet?.url) { // Use scramjet's URL property which contains the decoded URL pageURL = iframeWin.$scramjet.url.href; - } else { - pageURL = iframeWin.location.href; + upperSearchInput.value = pageURL; + return; } - upperSearchInput.value = pageURL; + // If proxy objects not available, fall through to decode from src } } catch (e) { - // Cross-origin error - try to get URL from iframe src - try { - const iframeSrc = iframe.src; - if (iframeSrc) { - // Decode URL from proxy prefix - if (iframeSrc.includes('/~/uv/')) { - // Extract and decode UV URL - const encoded = iframeSrc.split('/~/uv/')[1]; - if (encoded && typeof __uv$config !== 'undefined') { - try { - const decoded = __uv$config.decodeUrl!(encoded); - upperSearchInput.value = decoded; - } catch { - upperSearchInput.value = iframeSrc; - } + // Cross-origin error - will decode from iframe src below + } + + // Decode URL from iframe src (for both cross-origin and when proxy objects not available) + try { + const iframeSrc = iframe.src; + if (iframeSrc) { + // Decode URL from proxy prefix + if (iframeSrc.includes('/~/uv/')) { + // Extract and decode UV URL + const encoded = iframeSrc.split('/~/uv/')[1]; + if (encoded && typeof __uv$config !== 'undefined') { + try { + const decoded = __uv$config.decodeUrl!(encoded); + upperSearchInput.value = decoded; + } catch { + upperSearchInput.value = iframeSrc; } - } else if (iframeSrc.includes('/~/scramjet/')) { - // Extract and decode Scramjet URL - const encoded = iframeSrc.split('/~/scramjet/')[1]; - if (encoded && typeof $scramjetLoadController !== 'undefined') { - try { - const { ScramjetController } = $scramjetLoadController(); - // Create a temporary controller instance to decode - const tempController = new ScramjetController({ prefix: '/~/scramjet/' }); - const decoded = tempController.decodeUrl(encoded); - upperSearchInput.value = decoded; - } catch { - upperSearchInput.value = encoded; - } - } else { - upperSearchInput.value = encoded || iframeSrc; + } + } else if (iframeSrc.includes('/~/scramjet/')) { + // Extract and decode Scramjet URL + const encoded = iframeSrc.split('/~/scramjet/')[1]; + if (encoded && typeof $scramjetLoadController !== 'undefined') { + try { + const { ScramjetController } = $scramjetLoadController(); + // Create a temporary controller instance to decode + const tempController = new ScramjetController({ prefix: '/~/scramjet/' }); + const decoded = tempController.decodeUrl(encoded); + upperSearchInput.value = decoded; + } catch { + upperSearchInput.value = encoded; } } else { - upperSearchInput.value = iframeSrc; + upperSearchInput.value = encoded || iframeSrc; } + } else { + upperSearchInput.value = iframeSrc; } - } catch { - // Fallback - just leave the current value } + } catch { + // Fallback - just leave the current value } };