@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 1.22 kB
Source Map (JSON)
{"version":3,"file":"create-media-url.mjs","names":["constants"],"sources":["../../../src/utils/media/create-media-url.ts"],"sourcesContent":["import constants from \"../../constants/constants.js\";\nimport formatMediaBrowserKey from \"./format-media-browser-key.js\";\n\n/**\n * Used to create the url for the media.\n */\nconst createMediaUrl = (props: {\n\tkey: string;\n\thost: string;\n\tfileName?: string | null;\n\textension?: string | null;\n\tquery?: Record<string, string | undefined>;\n}) => {\n\tconst url = new URL(\n\t\t`${props.host}/${constants.directories.base}/cdn/${formatMediaBrowserKey({\n\t\t\tkey: props.key,\n\t\t\tfileName: props.fileName,\n\t\t\textension: props.extension,\n\t\t})}`,\n\t);\n\n\tfor (const [key, value] of Object.entries(props.query ?? {})) {\n\t\tif (!value) continue;\n\t\turl.searchParams.set(key, value);\n\t}\n\n\treturn url.toString();\n};\n\nexport default createMediaUrl;\n"],"mappings":"2FAMA,MAAM,EAAkB,GAMlB,CACL,IAAM,EAAM,IAAI,IACf,GAAG,EAAM,KAAK,GAAGA,EAAU,YAAY,KAAK,OAAO,EAAsB,CACxE,IAAK,EAAM,IACX,SAAU,EAAM,SAChB,UAAW,EAAM,SAClB,CAAC,GACF,EAEA,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAM,OAAS,CAAC,CAAC,EACrD,GACL,EAAI,aAAa,IAAI,EAAK,CAAK,EAGhC,OAAO,EAAI,SAAS,CACrB"}