Last active
December 24, 2015 21:59
-
-
Save jessepollak/6869105 to your computer and use it in GitHub Desktop.
Checking postMessage host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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