shoc-frontend-new/src/domain/work-orders/utils/display-file-name.ts

11 lines
460 B
TypeScript
Raw Normal View History

/**
* 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;
}