From 1269a3328cd7b6fa6dec3a46c169ca0f80e448ad Mon Sep 17 00:00:00 2001 From: Rachel Joyce Date: Thu, 1 Mar 2018 16:48:47 -0700 Subject: [PATCH] CR --- src/url.js | 1 + src/utils.js | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/url.js b/src/url.js index 502245f3abd..eb802c23b58 100644 --- a/src/url.js +++ b/src/url.js @@ -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, diff --git a/src/utils.js b/src/utils.js index 9fd0fb72ac5..c8ff5b62638 100644 --- a/src/utils.js +++ b/src/utils.js @@ -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; @@ -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); } @@ -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 {