Skip to content

Commit 631047d

Browse files
committed
Fixed eligrey#160: Made auto-BOM code toggleable
1 parent 9befa6c commit 631047d

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

FileSaver.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ var saveAs = saveAs || (function(view) {
7878
}
7979
return blob;
8080
}
81-
, FileSaver = function(blob, name) {
82-
blob = auto_bom(blob);
81+
, FileSaver = function(blob, name, no_auto_bom) {
82+
if (!no_auto_bom) {
83+
blob = auto_bom(blob);
84+
}
8385
// First try a.download, then web filesystem, then object URLs
8486
var
8587
filesaver = this
@@ -203,14 +205,17 @@ var saveAs = saveAs || (function(view) {
203205
}), fs_error);
204206
}
205207
, FS_proto = FileSaver.prototype
206-
, saveAs = function(blob, name) {
207-
return new FileSaver(blob, name);
208+
, saveAs = function(blob, name, no_auto_bom) {
209+
return new FileSaver(blob, name, no_auto_bom);
208210
}
209211
;
210212
// IE 10+ (native saveAs)
211213
if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) {
212-
return function(blob, name) {
213-
return navigator.msSaveOrOpenBlob(auto_bom(blob), name);
214+
return function(blob, name, no_auto_bom) {
215+
if (!no_auto_bom) {
216+
blob = auto_bom(blob);
217+
}
218+
return navigator.msSaveOrOpenBlob(blob, name || "download");
214219
};
215220
}
216221

FileSaver.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)