fix: parse out real url
This commit is contained in:
parent
4544e80eb1
commit
03595ac3de
|
@ -192,8 +192,12 @@ export function Browser() {
|
||||||
const handleIframeLoad = () => {
|
const handleIframeLoad = () => {
|
||||||
try {
|
try {
|
||||||
const newUrl = iframeRef?.current?.contentWindow?.location.href as string;
|
const newUrl = iframeRef?.current?.contentWindow?.location.href as string;
|
||||||
if (url !== newUrl) {
|
const urlObj = new URL(newUrl);
|
||||||
setUrl(newUrl);
|
let realUrl = urlObj.pathname
|
||||||
|
.replace(/^\/browse\//, "")
|
||||||
|
.replace(/\/$/, "");
|
||||||
|
if (url !== realUrl) {
|
||||||
|
setUrl(realUrl);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// This will catch errors related to cross-origin requests, in which case we can't access the iframe's contentWindow.location
|
// This will catch errors related to cross-origin requests, in which case we can't access the iframe's contentWindow.location
|
||||||
|
|
Loading…
Reference in New Issue