Skip to content

Commit b03b0db

Browse files
patrickhulcebrendankenny
authored andcommitted
fix: don't extend URL in url-shim to support es5 transpilation (#1407)
1 parent de25797 commit b03b0db

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

lighthouse-core/lib/url-shim.js

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,30 @@ URL.INVALID_URL_DEBUG_STRING =
3131
'Lighthouse was unable to determine the URL of some script executions. ' +
3232
'It\'s possible a Chrome extension or other eval\'d code is the source.';
3333

34-
class LighthouseURL extends URL {
35-
/**
36-
* @param {string} url
37-
* @return {boolean}
38-
*/
39-
static isValid(url) {
40-
try {
41-
new URL(url);
42-
return true;
43-
} catch (e) {
44-
return false;
45-
}
34+
/**
35+
* @param {string} url
36+
* @return {boolean}
37+
*/
38+
URL.isValid = function isValid(url) {
39+
try {
40+
new URL(url);
41+
return true;
42+
} catch (e) {
43+
return false;
4644
}
45+
};
4746

48-
/**
49-
* @param {string} urlA
50-
* @param {string} urlB
51-
* @return {boolean}
52-
*/
53-
static hostsMatch(urlA, urlB) {
54-
try {
55-
return new URL(urlA).host === new URL(urlB).host;
56-
} catch (e) {
57-
return false;
58-
}
47+
/**
48+
* @param {string} urlA
49+
* @param {string} urlB
50+
* @return {boolean}
51+
*/
52+
URL.hostsMatch = function hostsMatch(urlA, urlB) {
53+
try {
54+
return new URL(urlA).host === new URL(urlB).host;
55+
} catch (e) {
56+
return false;
5957
}
60-
}
58+
};
6159

62-
module.exports = LighthouseURL;
60+
module.exports = URL;

0 commit comments

Comments
 (0)