diff --git a/packages/core/src/urlPolyfill.ts b/packages/core/src/urlPolyfill.ts index 7a43013de8..75f3fe0f09 100644 --- a/packages/core/src/urlPolyfill.ts +++ b/packages/core/src/urlPolyfill.ts @@ -35,7 +35,7 @@ export function getHash(url: string) { function buildUrl(url: string, base?: string) { if (checkURLSupported()) { - return new URL(url, base) + return base !== undefined ? new URL(url, base) : new URL(url) } if (base === undefined && !/:/.test(url)) { throw new Error(`Invalid URL: '${url}'`) @@ -59,8 +59,9 @@ function checkURLSupported() { return isURLSupported } try { - const url = new URL('http://test') - return url.href === 'http://test' + const url = new URL('http://test/path') + isURLSupported = url.href === 'http://test/path' + return isURLSupported } catch { isURLSupported = false } diff --git a/test/static/async-e2e-page.html b/test/static/async-e2e-page.html index b6fe4277b7..3231ef644c 100644 --- a/test/static/async-e2e-page.html +++ b/test/static/async-e2e-page.html @@ -2,6 +2,7 @@
+