Skip to content

Commit 9bd5261

Browse files
Marcin Rybackijimmywarting
authored andcommitted
Catching an exception on Send. This happens when request for HEAD returns 405 Method Not Allowed. Instead of error http status, this may throw an exception. Return false and fallback to link download.
1 parent 3caf053 commit 9bd5261

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/FileSaver.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ function corsEnabled (url) {
4949
var xhr = new XMLHttpRequest()
5050
// use sync to avoid popup blocker
5151
xhr.open('HEAD', url, false)
52-
xhr.send()
52+
try {
53+
xhr.send();
54+
}catch(e) {
55+
return false;
56+
}
5357
return xhr.status >= 200 && xhr.status <= 299
5458
}
5559

0 commit comments

Comments
 (0)