Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catching an exception on Send. This happens when request for HEAD ret… #534

Merged
merged 2 commits into from May 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions dist/FileSaver.js
Expand Up @@ -30,7 +30,7 @@
if (typeof opts === 'undefined') opts = {
autoBom: false
};else if (typeof opts !== 'object') {
console.warn('Depricated: Expected third argument to be a object');
console.warn('Deprecated: Expected third argument to be a object');
opts = {
autoBom: !opts
};
Expand Down Expand Up @@ -66,7 +66,13 @@
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;
} // `a.click()` doesn't work for all browsers (#465)

Expand Down Expand Up @@ -135,7 +141,7 @@
} // Fallback to using FileReader and a popup
: function saveAs(blob, name, opts, popup) {
// Open a popup immediately do go around popup blocker
// Mostly only avalible on user interaction and the fileReader is async so...
// Mostly only available on user interaction and the fileReader is async so...
popup = popup || open('', '_blank');

if (popup) {
Expand All @@ -150,7 +156,7 @@
var isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent);

if ((isChromeIOS || force && isSafari) && typeof FileReader === 'object') {
// Safari doesn't allow downloading of blob urls
// Safari doesn't allow downloading of blob URLs
var reader = new FileReader();

reader.onloadend = function () {
Expand Down
2 changes: 1 addition & 1 deletion dist/FileSaver.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.