replace dots with underscores in save as filenames (#3565)

This commit is contained in:
Deep Tailor
2020-12-01 11:18:13 -08:00
committed by GitHub
parent 12727adb16
commit 6f810add43

View File

@ -117,8 +117,10 @@ define(
* @returns {promise} * @returns {promise}
*/ */
ExportImageService.prototype.exportJPG = function (element, filename, className) { ExportImageService.prototype.exportJPG = function (element, filename, className) {
const processedFilename = replaceDotsWithUnderscores(filename);
return this.renderElement(element, "jpg", className).then(function (img) { return this.renderElement(element, "jpg", className).then(function (img) {
saveAs(img, filename); saveAs(img, processedFilename);
}); });
}; };
@ -130,8 +132,10 @@ define(
* @returns {promise} * @returns {promise}
*/ */
ExportImageService.prototype.exportPNG = function (element, filename, className) { ExportImageService.prototype.exportPNG = function (element, filename, className) {
const processedFilename = replaceDotsWithUnderscores(filename);
return this.renderElement(element, "png", className).then(function (img) { return this.renderElement(element, "png", className).then(function (img) {
saveAs(img, filename); saveAs(img, processedFilename);
}); });
}; };
@ -146,6 +150,12 @@ define(
return this.renderElement(element, "png", className); return this.renderElement(element, "png", className);
}; };
function replaceDotsWithUnderscores(filename) {
const regex = /\./gi;
return filename.replace(regex, '_');
}
/** /**
* canvas.toBlob() not supported in IE < 10, Opera, and Safari. This polyfill * canvas.toBlob() not supported in IE < 10, Opera, and Safari. This polyfill
* implements the method in browsers that would not otherwise support it. * implements the method in browsers that would not otherwise support it.