9 lines
456 B
JavaScript
9 lines
456 B
JavaScript
/** Validate the non-secret default site embedded in the renderer at build time. */
|
|
export function defaultSite(value = 'https://ttp.joeykimsey.com') {
|
|
const url = new URL(value.trim())
|
|
if (!['https:', 'http:'].includes(url.protocol) || url.username || url.password || url.search || url.hash) {
|
|
throw new Error('CAPSULE_DEFAULT_SITE must be an HTTP(S) site URL without credentials, query, or fragment.')
|
|
}
|
|
return url.href.replace(/\/+$/, '')
|
|
}
|