diff --git a/fetch.js b/fetch.js index f1ade0dc20a28c1d47269f5db5e029e6a8f95f76..08cd0fbbfdc667179a0052c1418077cc5c0360f9 100644 --- a/fetch.js +++ b/fetch.js @@ -486,7 +486,15 @@ export function fetch(input, init) { reject(new DOMException('Aborted', 'AbortError')) } - xhr.open(request.method, request.url, true) + function fixUrl(url) { + try { + return url === '' && self.location.href ? self.location.href : url + } catch (e) { + return url + } + } + + xhr.open(request.method, fixUrl(request.url), true) if (request.credentials === 'include') { xhr.withCredentials = true