mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-12-02 02:17:01 +00:00
17 lines
517 B
TypeScript
17 lines
517 B
TypeScript
|
import { config } from "../Config";
|
||
|
|
||
|
export function isInvalidParentFrameOrigin(event: MessageEvent): boolean {
|
||
|
return !isValidOrigin(config.allowedParentFrameOrigins, event);
|
||
|
}
|
||
|
|
||
|
function isValidOrigin(allowedOrigins: RegExp, event: MessageEvent): boolean {
|
||
|
const eventOrigin = (event && event.origin) || "";
|
||
|
const windowOrigin = (window && window.origin) || "";
|
||
|
if (eventOrigin === windowOrigin) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
const result = allowedOrigins && allowedOrigins.test(eventOrigin);
|
||
|
return result;
|
||
|
}
|