From a900d7d0e26d0dede8fa45ab723e9e64f7879b26 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Thu, 28 May 2020 11:05:21 +0100 Subject: [PATCH] work around IE XHR bug with '' URL Fixes #618 (#619) Co-authored-by: Jake Champion --- fetch.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fetch.js b/fetch.js index f1ade0dc..08cd0fbb 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