mirror of
https://github.com/nasa/openmct.git
synced 2025-06-17 06:38:17 +00:00
replace dots with underscores in save as filenames (#3565)
This commit is contained in:
@ -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.
|
||||||
|
Reference in New Issue
Block a user