Skip to content

Commit 577a233

Browse files
committed
add better filename
1 parent 009f890 commit 577a233

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ if (input) input.onchange = async (e: Event) => {
1313
const file = element.files[0];
1414
const compressedFile = await compressFile(file);
1515
const dataURI = await getBase64Image(compressedFile);
16+
const fullName = file.name;
17+
const fullNameArray = fullName.split('.');
18+
const extension = fullNameArray.pop();
19+
const fileName = fullNameArray.join('.');
1620
downloadElement.href = dataURI;
1721
statusElement.style.display = 'none';
1822
downloadElement.style.display = '';
23+
downloadElement.download = `${fileName}-min.${extension}`;
1924
}
2025

2126
let quality = 1;

0 commit comments

Comments
 (0)