fix: parse out real url

This commit is contained in:
Derrick Hammer 2023-10-16 21:46:30 -04:00
parent 4544e80eb1
commit 03595ac3de
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 2 deletions

View File

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