From 03595ac3deecdf58d6dff7989029627dee056775 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 16 Oct 2023 21:46:30 -0400 Subject: [PATCH] fix: parse out real url --- src/components/Browser.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Browser.tsx b/src/components/Browser.tsx index 467e684..2141f8b 100644 --- a/src/components/Browser.tsx +++ b/src/components/Browser.tsx @@ -192,8 +192,12 @@ export function Browser() { const handleIframeLoad = () => { try { const newUrl = iframeRef?.current?.contentWindow?.location.href as string; - if (url !== newUrl) { - setUrl(newUrl); + const urlObj = new URL(newUrl); + let realUrl = urlObj.pathname + .replace(/^\/browse\//, "") + .replace(/\/$/, ""); + if (url !== realUrl) { + setUrl(realUrl); } } catch (e) { // This will catch errors related to cross-origin requests, in which case we can't access the iframe's contentWindow.location