fix: should check specifically for if pathname is undefined or empty

This commit is contained in:
Jacob Overgaard
2024-11-26 09:08:22 +01:00
committed by nikolajlauridsen
parent b6551d63b7
commit 72596bd853

View File

@@ -22,11 +22,12 @@ export function hasOwnOpener(pathname?: string, windowLike: Window = globalThis.
return false; return false;
} }
if (pathname && openerLocation.pathname.startsWith(pathname)) { // If there is a pathname, check if the opener has the same pathname
return true; if (typeof pathname !== 'undefined' && !openerLocation.pathname.startsWith(pathname)) {
return false;
} }
return false; return true;
} catch { } catch {
// If there is a security error, it means that the opener is from a different origin, so we let it fall through // If there is a security error, it means that the opener is from a different origin, so we let it fall through
return false; return false;