Skip to content

Commit 940b3cd

Browse files
committed
Add URL try/catch
1 parent 413ef2f commit 940b3cd

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/utils/resolve-url.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ export function resolveUrl(url, baseURI) {
2828
if (url && ABS_URL.test(url)) {
2929
return url;
3030
}
31-
if (url === '//') {
32-
return url;
33-
}
3431
// Lazy feature detection.
3532
if (workingURL === undefined) {
3633
workingURL = false;
@@ -46,7 +43,12 @@ export function resolveUrl(url, baseURI) {
4643
baseURI = document.baseURI || window.location.href;
4744
}
4845
if (workingURL) {
49-
return (new URL(url, baseURI)).href;
46+
try {
47+
return (new URL(url, baseURI)).href;
48+
} catch (e) {
49+
// Bad url or baseURI structure. Do not attempt to resolve.
50+
return url;
51+
}
5052
}
5153
// Fallback to creating an anchor into a disconnected document.
5254
if (!resolveDoc) {

0 commit comments

Comments
 (0)