Skip to content

Commit

Permalink
work around IE XHR bug with '' URL Fixes #618 (#619)
Browse files Browse the repository at this point in the history
Co-authored-by: Jake Champion <me@jakechampion.name>
  • Loading branch information
graingert and JakeChampion committed May 28, 2020
1 parent 92d78df commit a900d7d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fetch.js
Expand Up @@ -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
Expand Down

0 comments on commit a900d7d

Please sign in to comment.