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:
Cameron Fischer
2025-10-21 06:53:32 -04:00
committed by GitHub
parent 276fdc8634
commit 8168512e95

View File

@@ -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 {