@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 1.36 kB
Source Map (JSON)
{"version":3,"file":"get-email-from.mjs","names":[],"sources":["../../../src/utils/helpers/get-email-from.ts"],"sourcesContent":["import type { Config } from \"../../types/config.js\";\n\n/**\n * Returns the email \"from\" values based on the following priority:\n * 1. If config.email.from is set, use it\n * 2. If a host URL is provided, use noreply@{host} and \"Lucid CMS\" for the name\n * 3. Fallback to noreply@example.com and \"Lucid CMS\" for the name\n */\nconst getEmailFrom = (\n\tconfig: Config,\n\turl: string | undefined,\n): {\n\temail: string;\n\tname: string;\n} => {\n\tif (config.email.from?.email && config.email.from?.name) {\n\t\treturn {\n\t\t\temail: config.email.from.email,\n\t\t\tname: config.email.from.name,\n\t\t};\n\t}\n\n\tif (url) {\n\t\ttry {\n\t\t\tconst parsedUrl = new URL(url);\n\t\t\treturn {\n\t\t\t\temail: `noreply@${parsedUrl.hostname}`,\n\t\t\t\tname: \"Lucid CMS\",\n\t\t\t};\n\t\t} catch {}\n\t}\n\n\treturn {\n\t\temail: \"noreply@example.com\",\n\t\tname: \"Lucid CMS\",\n\t};\n};\n\nexport default getEmailFrom;\n"],"mappings":"AAQA,MAAM,GACL,EACA,IAII,CACJ,GAAI,EAAO,MAAM,MAAM,OAAS,EAAO,MAAM,MAAM,KAClD,MAAO,CACN,MAAO,EAAO,MAAM,KAAK,MACzB,KAAM,EAAO,MAAM,KAAK,IACzB,EAGD,GAAI,EACH,GAAI,CAEH,MAAO,CACN,MAAO,WAAW,IAFG,IAAI,CAEC,CAAC,CAAC,WAC5B,KAAM,WACP,CACD,MAAQ,CAAC,CAGV,MAAO,CACN,MAAO,sBACP,KAAM,WACP,CACD"}