Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function parse(url, options) {
parsed.href = decodeURIComponent(url);
}
return {
href: parsed.href,
protocol: (parsed.protocol || '').replace(/:$/, ''),
hostname: parsed.hostname,
port: +parsed.port,
Expand Down
11 changes: 5 additions & 6 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { config } from './config';
import clone from 'just-clone';
import find from 'core-js/library/fn/array/find';
import includes from 'core-js/library/fn/array/includes';
import { parse } from './url';

var CONSTANTS = require('./constants');

var _loggingChecked = false;
Expand Down Expand Up @@ -175,10 +177,12 @@ const getIframeParentLoc = function() {
window.document.location.ancestorOrigins.length >= 1) {
loc = window.document.location.ancestorOrigins[window.document.location.ancestorOrigins.length - 1];
} else if (window.document.location) {
// force an exception in x-domain environments. #1509
window.top.location.toString();
loc = getNonWebKitIframeParentLoc();
}
}
loc = parseFullUrl(loc);
loc = parse(loc);
} catch (e) {
this.logMessage('getTopParentLoc failure', e);
}
Expand All @@ -198,11 +202,6 @@ const getNonWebKitIframeParentLoc = function() {
return referrerLoc;
};

const parseFullUrl = function(locString) {
const match = locString.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
return match && {protocol: match[1], host: match[2], hostname: match[3], port: match[4], pathname: match[5], search: match[6], hash: match[7], href: match.input};
};

exports.getTopWindowUrl = function () {
let href;
try {
Expand Down