File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -53,13 +53,15 @@ vAPI.download = function(details) {
53
53
return ;
54
54
}
55
55
56
- var contentMatches = details . url . match ( 'data:([^;,]+).*,(.*)$' ) ;
56
+ const contentMatches = details . url . match ( 'data:([^;,]+).*,(.*)$' ) ;
57
57
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
63
65
window . navigator . msSaveBlob ( blob , details . filename ) ;
64
66
}
65
67
} ;
You can’t perform that action at this time.
0 commit comments