mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-02-02 02:46:46 +00:00
Support for downloading base64 files (#9297)
* Support for downloading base64 files * Added comment explaining why we'd use data urls over blobs * Using more modern string##includes method
This commit is contained in:
@@ -35,7 +35,9 @@ DownloadSaver.prototype.save = function(text,method,callback,options) {
|
||||
}
|
||||
// Set up the link
|
||||
var link = document.createElement("a");
|
||||
if(Blob !== undefined) {
|
||||
// We prefer Blobs if they're available, unless we're dealing with a tiddler type declaring itself full of base64 encoded content.
|
||||
// Then we use data urls, because browsers will know to decode the stream and download the actual binary file as intended.
|
||||
if(Blob !== undefined && !type.includes(";base64")) {
|
||||
var blob = new Blob([text], {type: type});
|
||||
link.setAttribute("href", URL.createObjectURL(blob));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user