Skip to content

Commit

Permalink
fix: don't extend URL in url-shim to support es5 transpilation (#1407)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce authored and brendankenny committed Jan 5, 2017
1 parent de25797 commit b03b0db
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions lighthouse-core/lib/url-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,30 @@ URL.INVALID_URL_DEBUG_STRING =
'Lighthouse was unable to determine the URL of some script executions. ' +
'It\'s possible a Chrome extension or other eval\'d code is the source.';

class LighthouseURL extends URL {
/**
* @param {string} url
* @return {boolean}
*/
static isValid(url) {
try {
new URL(url);
return true;
} catch (e) {
return false;
}
/**
* @param {string} url
* @return {boolean}
*/
URL.isValid = function isValid(url) {
try {
new URL(url);
return true;
} catch (e) {
return false;
}
};

/**
* @param {string} urlA
* @param {string} urlB
* @return {boolean}
*/
static hostsMatch(urlA, urlB) {
try {
return new URL(urlA).host === new URL(urlB).host;
} catch (e) {
return false;
}
/**
* @param {string} urlA
* @param {string} urlB
* @return {boolean}
*/
URL.hostsMatch = function hostsMatch(urlA, urlB) {
try {
return new URL(urlA).host === new URL(urlB).host;
} catch (e) {
return false;
}
}
};

module.exports = LighthouseURL;
module.exports = URL;

0 comments on commit b03b0db

Please sign in to comment.