fix(downloads): stop repeating an extension the name already carries

A voice comment's display name is the generated file name, extension
included, so appending the extension again downloaded it as
<uuid>.webm.webm. Both download paths, the single asset route and the
project zip, now append only when the name does not already end in it.
This commit is contained in:
yusufipk
2026-07-30 23:13:04 +07:00
parent e7008c571a
commit 93e85683e9
5 changed files with 69 additions and 8 deletions
+8
View File
@@ -66,6 +66,14 @@ export function sanitizeAssetDisplayName(
return normalized.slice(0, 200);
}
/**
* A voice comment's display name is the generated file name, extension and all,
* so blindly appending the extension named the download `<uuid>.webm.webm`.
*/
export function withFileExtension(name: string, extension: string): string {
return name.toLowerCase().endsWith(extension.toLowerCase()) ? name : `${name}${extension}`;
}
export function extractImageKeyFromProxyUrl(url: string): string | null {
if (!SAFE_IMAGE_PROXY_PATH.test(url)) return null;
const filename = url.slice(IMAGE_PROXY_PREFIX.length);