mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-04 10:12:05 +00:00
11 lines
460 B
TypeScript
11 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;
|
||
|
|
}
|