mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-26 20:31:33 +00:00
Initial Move from Azure DevOps to GitHub
This commit is contained in:
16
src/Utils/MessageValidation.ts
Normal file
16
src/Utils/MessageValidation.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user