Skip to content

Commit

Permalink
Catching an exception on Send. This happens when request for HEAD ret…
Browse files Browse the repository at this point in the history
…urns 405 Method Not Allowed. Instead of error http status, this may throw an exception. Return false and fallback to link download.
  • Loading branch information
Marcin Rybacki authored and jimmywarting committed May 14, 2019
1 parent 3caf053 commit 9bd5261
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/FileSaver.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ function corsEnabled (url) {
var xhr = new XMLHttpRequest()
// use sync to avoid popup blocker
xhr.open('HEAD', url, false)
xhr.send()
try {
xhr.send();
}catch(e) {
return false;
}
return xhr.status >= 200 && xhr.status <= 299
}

Expand Down

0 comments on commit 9bd5261

Please sign in to comment.