Skip to content

Commit e57ebbe

Browse files
Merge pull request gorhill#28 from nikrolls/export-fixes
Convert exported plaintext files to CRLF
2 parents fab366b + 4666951 commit e57ebbe

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

platform/edge/vapi-common.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ vAPI.download = function(details) {
5353
return;
5454
}
5555

56-
var contentMatches = details.url.match('data:([^;,]+).*,(.*)$');
56+
const contentMatches = details.url.match('data:([^;,]+).*,(.*)$');
5757
if(contentMatches && contentMatches.length === 3) {
58-
var contentType = contentMatches && contentMatches[1] || 'text/plain';
59-
var content = decodeURIComponent(contentMatches[2]);
60-
var blob = new Blob([content], {type: contentType});
61-
// Currently not working; Edge doesn't allow downloads from background
62-
// pages
58+
const contentType = contentMatches && contentMatches[1] || 'text/plain';
59+
let content = decodeURIComponent(contentMatches[2]);
60+
if ( contentType === 'text/plain' ) {
61+
content = content.replace(/\r?\n/g, '\r\n');
62+
}
63+
const blob = new Blob([content], {type: contentType});
64+
// Currently not working from background pages
6365
window.navigator.msSaveBlob(blob, details.filename);
6466
}
6567
};

0 commit comments

Comments
 (0)