shoc-frontend-new/src/domain/work-orders/utils/display-file-name.ts
Arthur Bassi 74e5c58e5d fix(work-orders): restore completion media uploads over HTTP/1.1
Use XHR for media progress so Ky does not stream the body on HTTP/1.1
(Vite proxy), and keep completion vs extra tiles from mixing after upload.
2026-09-07 15:19:39 -03:00

10 lines
460 B
TypeScript

/**
* why: uploads are stored as `{guid}_{original name}`, so the raw storage name shown in media
* tiles reads as an id. The original name (and its extension) survive after the prefix.
*/
const STORED_NAME_PREFIX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}_/i;
export function toDisplayFileName(fileName: string): string {
const withoutPrefix = fileName.replace(STORED_NAME_PREFIX, "").trim();
return withoutPrefix || fileName;
}