Skip to content

Commit

Permalink
work around IE XHR bug with '' URL Fixes #618
Browse files Browse the repository at this point in the history
Fix when running on Firefox with fetchPonyfill (and any other error
cases)
  • Loading branch information
graingert committed Apr 18, 2018
1 parent cbb313b commit 1b56f16
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fetch.js
Expand Up @@ -342,6 +342,14 @@
Request.prototype.clone = function() {
return new Request(this, { body: this._bodyInit })
}

function fixUrl(url) {
try {
return url === '' && self.location.href ? self.location.href : url
} catch(e) {
return url;
}
}

function decode(body) {
var form = new FormData()
Expand Down Expand Up @@ -443,7 +451,7 @@
reject(new TypeError('Network request failed'))
}

xhr.open(request.method, request.url, true)

This comment has been minimized.

Copy link
@sunginw

sunginw Jul 13, 2018

ทำไฝ

This comment has been minimized.

Copy link
@graingert

graingert Jul 13, 2018

Author Contributor

Make a mole?

This comment has been minimized.

Copy link
@abdourahimjallow

abdourahimjallow Jul 14, 2018

Cool

xhr.open(request.method, fixUrl(request.url), true)

if (request.credentials === 'include') {
xhr.withCredentials = true
Expand Down

0 comments on commit 1b56f16

Please sign in to comment.