UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

1 lines 1.02 kB
{"version":3,"file":"normalize-media-key.mjs","names":[],"sources":["../../../src/utils/media/normalize-media-key.ts"],"sourcesContent":["import { getMediaKeyParts } from \"./media-key-tenant.js\";\n\n/**\n * Converts a browser-facing media path back into the canonical storage key.\n * The visual filename segment is ignored so display URLs resolve to storage keys.\n */\nconst normalizeMediaKey = (key: string) => {\n\tconst keyParts = getMediaKeyParts(key);\n\tif (keyParts.parts.length === 0) return key;\n\n\tif (keyParts.rootIndex === -1) return keyParts.parts.join(\"/\");\n\n\tif (keyParts.identity) {\n\t\treturn keyParts.parts.slice(0, keyParts.identityIndex + 1).join(\"/\");\n\t}\n\n\treturn keyParts.parts.join(\"/\");\n};\n\nexport default normalizeMediaKey;\n"],"mappings":"0DAMA,MAAM,EAAqB,GAAgB,CAC1C,IAAM,EAAW,EAAiB,CAAG,EASrC,OARI,EAAS,MAAM,SAAW,EAAU,EAEpC,EAAS,YAAc,GAAW,EAAS,MAAM,KAAK,GAAG,EAEzD,EAAS,SACL,EAAS,MAAM,MAAM,EAAG,EAAS,cAAgB,CAAC,CAAC,CAAC,KAAK,GAAG,EAG7D,EAAS,MAAM,KAAK,GAAG,CAC/B"}