chore: move from png to image-generic

This commit is contained in:
Ibrahima G. Coulibaly
2025-04-02 20:48:00 +00:00
parent 92858f2e24
commit a0ebd9c3b6
18 changed files with 125 additions and 101 deletions

View File

@@ -52,8 +52,17 @@ export default function ToolFileResult({
if (value) {
let filename: string = value.name;
if (extension) {
const hasExtension = filename.includes('.');
filename = hasExtension ? filename : `${filename}.${extension}`;
// Split at the last period to separate filename and extension
const parts = filename.split('.');
// If there's more than one part (meaning there was a period)
if (parts.length > 1) {
// Remove the last part (the extension) and add the new extension
parts.pop();
filename = `${parts.join('.')}.${extension}`;
} else {
// No extension exists, just add it
filename = `${filename}.${extension}`;
}
}
const blob = new Blob([value], { type: value.type });
const url = window.URL.createObjectURL(blob);