file-saver
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -7,5 +7,9 @@ # Changelog | ||
## [2.0.2] - 2019-05-14 | ||
- Catching an exception on Send (HEAD) ([#534]) | ||
## [2.0.0] - 2018-10-17 | ||
- Removed eval to resolve CSP [#465] | ||
- Removed eval to resolve CSP ([#465]) | ||
@@ -57,1 +61,2 @@ ## [2.0.0-rc.4] - 2018-10-17 | ||
[#491]: https://github.com/eligrey/FileSaver.js/issues/491 | ||
[#534]: https://github.com/eligrey/FileSaver.js/issues/534 |
@@ -69,3 +69,7 @@ (function (global, factory) { | ||
xhr.open('HEAD', url, false); | ||
xhr.send(); | ||
try { | ||
xhr.send(); | ||
} catch (e) {} | ||
return xhr.status >= 200 && xhr.status <= 299; | ||
@@ -72,0 +76,0 @@ } // `a.click()` doesn't work for all browsers (#465) |
@@ -1,3 +0,3 @@ | ||
(function(a,b){if("function"==typeof define&&define.amd)define([],b);else if("undefined"!=typeof exports)b();else{b(),a.FileSaver={exports:{}}.exports}})(this,function(){"use strict";function b(a,b){return"undefined"==typeof b?b={autoBom:!1}:"object"!=typeof b&&(console.warn("Deprecated: Expected third argument to be a object"),b={autoBom:!b}),b.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\uFEFF",a],{type:a.type}):a}function c(b,c,d){var e=new XMLHttpRequest;e.open("GET",b),e.responseType="blob",e.onload=function(){a(e.response,c,d)},e.onerror=function(){console.error("could not download file")},e.send()}function d(a){var b=new XMLHttpRequest;return b.open("HEAD",a,!1),b.send(),200<=b.status&&299>=b.status}function e(a){try{a.dispatchEvent(new MouseEvent("click"))}catch(c){var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(b)}}var f="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof global&&global.global===global?global:void 0,a=f.saveAs||("object"!=typeof window||window!==f?function(){}:"download"in HTMLAnchorElement.prototype?function(b,g,h){var i=f.URL||f.webkitURL,j=document.createElement("a");g=g||b.name||"download",j.download=g,j.rel="noopener","string"==typeof b?(j.href=b,j.origin===location.origin?e(j):d(j.href)?c(b,g,h):e(j,j.target="_blank")):(j.href=i.createObjectURL(b),setTimeout(function(){i.revokeObjectURL(j.href)},4E4),setTimeout(function(){e(j)},0))}:"msSaveOrOpenBlob"in navigator?function(f,g,h){if(g=g||f.name||"download","string"!=typeof f)navigator.msSaveOrOpenBlob(b(f,h),g);else if(d(f))c(f,g,h);else{var i=document.createElement("a");i.href=f,i.target="_blank",setTimeout(function(){e(i)})}}:function(a,b,d,e){if(e=e||open("","_blank"),e&&(e.document.title=e.document.body.innerText="downloading..."),"string"==typeof a)return c(a,b,d);var g="application/octet-stream"===a.type,h=/constructor/i.test(f.HTMLElement)||f.safari,i=/CriOS\/[\d]+/.test(navigator.userAgent);if((i||g&&h)&&"object"==typeof FileReader){var j=new FileReader;j.onloadend=function(){var a=j.result;a=i?a:a.replace(/^data:[^;]*;/,"data:attachment/file;"),e?e.location.href=a:location=a,e=null},j.readAsDataURL(a)}else{var k=f.URL||f.webkitURL,l=k.createObjectURL(a);e?e.location=l:location.href=l,e=null,setTimeout(function(){k.revokeObjectURL(l)},4E4)}});f.saveAs=a.saveAs=a,"undefined"!=typeof module&&(module.exports=a)}); | ||
(function(a,b){if("function"==typeof define&&define.amd)define([],b);else if("undefined"!=typeof exports)b();else{b(),a.FileSaver={exports:{}}.exports}})(this,function(){"use strict";function b(a,b){return"undefined"==typeof b?b={autoBom:!1}:"object"!=typeof b&&(console.warn("Deprecated: Expected third argument to be a object"),b={autoBom:!b}),b.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\uFEFF",a],{type:a.type}):a}function c(b,c,d){var e=new XMLHttpRequest;e.open("GET",b),e.responseType="blob",e.onload=function(){a(e.response,c,d)},e.onerror=function(){console.error("could not download file")},e.send()}function d(a){var b=new XMLHttpRequest;b.open("HEAD",a,!1);try{b.send()}catch(a){}return 200<=b.status&&299>=b.status}function e(a){try{a.dispatchEvent(new MouseEvent("click"))}catch(c){var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(b)}}var f="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof global&&global.global===global?global:void 0,a=f.saveAs||("object"!=typeof window||window!==f?function(){}:"download"in HTMLAnchorElement.prototype?function(b,g,h){var i=f.URL||f.webkitURL,j=document.createElement("a");g=g||b.name||"download",j.download=g,j.rel="noopener","string"==typeof b?(j.href=b,j.origin===location.origin?e(j):d(j.href)?c(b,g,h):e(j,j.target="_blank")):(j.href=i.createObjectURL(b),setTimeout(function(){i.revokeObjectURL(j.href)},4E4),setTimeout(function(){e(j)},0))}:"msSaveOrOpenBlob"in navigator?function(f,g,h){if(g=g||f.name||"download","string"!=typeof f)navigator.msSaveOrOpenBlob(b(f,h),g);else if(d(f))c(f,g,h);else{var i=document.createElement("a");i.href=f,i.target="_blank",setTimeout(function(){e(i)})}}:function(a,b,d,e){if(e=e||open("","_blank"),e&&(e.document.title=e.document.body.innerText="downloading..."),"string"==typeof a)return c(a,b,d);var g="application/octet-stream"===a.type,h=/constructor/i.test(f.HTMLElement)||f.safari,i=/CriOS\/[\d]+/.test(navigator.userAgent);if((i||g&&h)&&"object"==typeof FileReader){var j=new FileReader;j.onloadend=function(){var a=j.result;a=i?a:a.replace(/^data:[^;]*;/,"data:attachment/file;"),e?e.location.href=a:location=a,e=null},j.readAsDataURL(a)}else{var k=f.URL||f.webkitURL,l=k.createObjectURL(a);e?e.location=l:location.href=l,e=null,setTimeout(function(){k.revokeObjectURL(l)},4E4)}});f.saveAs=a.saveAs=a,"undefined"!=typeof module&&(module.exports=a)}); | ||
//# sourceMappingURL=FileSaver.min.js.map |
{ | ||
"name": "file-saver", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "An HTML5 saveAs() FileSaver implementation", | ||
@@ -5,0 +5,0 @@ "main": "dist/FileSaver.min.js", |
@@ -11,3 +11,3 @@ If you need to save really large files bigger then the blob's size limitation or don't have | ||
web apps that generates files on the client, However if the file is coming from the | ||
server we recommend you to first try to use [Content-Disposition][8] attachment response header as it has more cross-browser compatible | ||
server we recommend you to first try to use [Content-Disposition][8] attachment response header as it has more cross-browser compatiblity. | ||
@@ -24,4 +24,4 @@ Looking for `canvas.toBlob()` for saving canvases? Check out | ||
| Firefox < 20 | data: URI | No | n/a | [Blob.js](https://github.com/eligrey/Blob.js) | | ||
| Chrome | Blob | Yes | [500 MiB][3] | None | | ||
| Chrome for Android | Blob | Yes | [500 MiB][3] | None | | ||
| Chrome | Blob | Yes | [2GB][3] | None | | ||
| Chrome for Android | Blob | Yes | [RAM/5][3] | None | | ||
| Edge | Blob | Yes | ? | None | | ||
@@ -65,6 +65,6 @@ | IE 10+ | Blob | Yes | 600 MiB | None | | ||
```js | ||
FileSaver saveAs(Blob/File/Url, optional DOMString filename, optional Object { autoBOM }) | ||
FileSaver saveAs(Blob/File/Url, optional DOMString filename, optional Object { autoBom }) | ||
``` | ||
Pass `{ autoBOM: true }` if you want FileSaver.js to automatically provide Unicode text encoding hints (see: [byte order mark](https://en.wikipedia.org/wiki/Byte_order_mark)). | ||
Pass `{ autoBom: true }` if you want FileSaver.js to automatically provide Unicode text encoding hints (see: [byte order mark](https://en.wikipedia.org/wiki/Byte_order_mark)). Note that this is only done if your blob type has `charset=utf-8` set. | ||
@@ -93,6 +93,6 @@ Examples | ||
``` | ||
Using URLs within the same origin will just use `a[download]` | ||
Otherwise, it will first check if it supports cors header with a synchronously head request | ||
if it does it will download the data and save it using blob URLs | ||
if not it will try to download it using `a[download]` | ||
Using URLs within the same origin will just use `a[download]`. | ||
Otherwise, it will first check if it supports cors header with a synchronous head request. | ||
If it does, it will download the data and save using blob URLs. | ||
If not, it will try to download it using `a[download]`. | ||
@@ -115,6 +115,6 @@ The standard W3C File API [`Blob`][4] interface is not available in all browsers. | ||
You can save a File constructor without specifying a filename. The | ||
File itself already contains a name, There is a hand full of ways to get a file | ||
instance (from storage, file input, new constructor, clipboard event) | ||
But if you still want to change the name, then you can change it in the 2nd argument | ||
You can save a File constructor without specifying a filename. If the | ||
file itself already contains a name, there is a hand full of ways to get a file | ||
instance (from storage, file input, new constructor, clipboard event). | ||
If you still want to change the name, then you can change it in the 2nd argument. | ||
@@ -134,3 +134,3 @@ ```js | ||
[2]: https://github.com/eligrey/canvas-toBlob.js | ||
[3]: https://code.google.com/p/chromium/issues/detail?id=375297 | ||
[3]: https://bugs.chromium.org/p/chromium/issues/detail?id=375297#c107 | ||
[4]: https://developer.mozilla.org/en-US/docs/DOM/Blob | ||
@@ -137,0 +137,0 @@ [5]: https://github.com/eligrey/Blob.js |
@@ -11,3 +11,2 @@ /* | ||
// The one and only way of getting global scope in all environments | ||
@@ -53,3 +52,5 @@ // https://stackoverflow.com/q/3277182/1008999 | ||
xhr.open('HEAD', url, false) | ||
xhr.send() | ||
try { | ||
xhr.send() | ||
} catch (e) {} | ||
return xhr.status >= 200 && xhr.status <= 299 | ||
@@ -59,3 +60,3 @@ } | ||
// `a.click()` doesn't work for all browsers (#465) | ||
function click(node) { | ||
function click (node) { | ||
try { | ||
@@ -62,0 +63,0 @@ node.dispatchEvent(new MouseEvent('click')) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34164
313