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 Mads Rasmussen
parent b6551d63b7
commit 1b3782f2b0

View File

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