Skip to content

Instantly share code, notes, and snippets.

@jessepollak
Last active December 24, 2015 21:59
Show Gist options
  • Save jessepollak/6869105 to your computer and use it in GitHub Desktop.
Save jessepollak/6869105 to your computer and use it in GitHub Desktop.
Checking postMessage host
normalize = function(url) {
var parser;
parser = document.createElement('a');
parser.href = url;
return "" + parser.protocol + "//" + parser.host;
};
function handleMessage(e) {
// ...
if (normalize(e.origin) !== 'https://clef.io') {
return;
}
// ...
}
$(window).on('message', handleMessage);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment