Skip to content

Commit

Permalink
Merge pull request #341 from davedevelopment/origin-alternative
Browse files Browse the repository at this point in the history
Makes origin checking compatible with IE11 + possibly others
  • Loading branch information
chrissrogers authored Mar 14, 2017
2 parents 7b462bb + 0d67b7d commit 35a43c5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/recurly/relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function relay (done) {
}

events.bind(window, 'message', function listener (event) {
if (event.origin !== origin()) return;
if (origin(event.origin) !== origin(self.config.api)) return;

var data = JSON.parse(event.data);
var name = data.recurly_event;
Expand All @@ -49,10 +49,10 @@ function relay (done) {
done();
}

function origin () {
function origin (url) {
var parser = document.createElement('a');
parser.href = self.config.api;
parser.href = url

return parser.origin;
return `${parser.protocol}//${parser.host}`;
}
}

0 comments on commit 35a43c5

Please sign in to comment.