Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #35 from fmarier/bug878485
Browse files Browse the repository at this point in the history
Bug878485
  • Loading branch information
fmarier committed Feb 8, 2014
2 parents 2c9c964 + b8dae49 commit ac4b142
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions winchan.js
Expand Up @@ -56,19 +56,19 @@
// given a URL, extract the origin
function extractOrigin(url) {
if (!/^https?:\/\//.test(url)) url = window.location.href;
var m = /^(https?:\/\/[\-_a-zA-Z\.0-9:]+)/.exec(url);
if (m) return m[1];
return url;
var a = document.createElement('a');
a.href = url;
return a.protocol + "//" + a.host;
}

// find the relay iframe in the opener
function findRelay() {
var loc = window.location;
var frames = window.opener.frames;
var origin = loc.protocol + '//' + loc.host;
for (var i = frames.length - 1; i >= 0; i--) {
try {
if (frames[i].location.href.indexOf(origin) === 0 &&
if (frames[i].location.protocol === window.location.protocol &&
frames[i].location.host === window.location.host &&
frames[i].name === RELAY_FRAME_NAME)
{
return frames[i];
Expand Down

0 comments on commit ac4b142

Please sign in to comment.