Skip to content

Commit 147cf92

Browse files
committed
Fixing BOM prepending in IE10
Thanks for pointing it out @ruifcardoso
1 parent 239f3c4 commit 147cf92

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

FileSaver.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* FileSaver.js
22
* A saveAs() FileSaver implementation.
3-
* 2015-03-04
3+
* 2015-05-07
44
*
55
* By Eli Grey, http://eligrey.com
66
* License: X11/MIT
@@ -125,6 +125,10 @@ var saveAs = saveAs
125125
if (!name) {
126126
name = "download";
127127
}
128+
// prepend BOM for UTF-8 XML and text/plain types
129+
if (/^\s*(?:text\/(?:plain|xml)|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
130+
blob = new Blob(["\ufeff", blob], {type: blob.type});
131+
}
128132
if (can_use_save_link) {
129133
object_url = get_URL().createObjectURL(blob);
130134
save_link.href = object_url;
@@ -135,10 +139,6 @@ var saveAs = saveAs
135139
revoke(object_url);
136140
return;
137141
}
138-
// prepend BOM for UTF-8 XML and text/plain types
139-
if (/^\s*(?:text\/(?:plain|xml)|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
140-
blob = new Blob(["\ufeff", blob], {type: blob.type});
141-
}
142142
// Object and web filesystem URLs have a problem saving in Google Chrome when
143143
// viewed in a tab, so I force save with application/octet-stream
144144
// http://code.google.com/p/chromium/issues/detail?id=91158

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)