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.

This commit is contained in:
Marcin Rybacki
2019-05-14 09:46:41 +02:00
committed by Jimmy Wärting
parent 3caf053bbd
commit 9bd5261f60
+5 -1
View File
@@ -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
}