mirror of
https://github.com/Extroonie/extroonie.com.git
synced 2026-10-13 01:48:06 -07:00
19 lines
526 B
JavaScript
19 lines
526 B
JavaScript
|
|
import { readFileSync } from 'node:fs';
|
||
|
|
|
||
|
|
export function siteBaseURL() {
|
||
|
|
const { baseURL } = Bun.TOML.parse(readFileSync(new URL('../hugo.toml', import.meta.url), 'utf8'));
|
||
|
|
const url = new URL(process.env.SITE_BASE_URL || baseURL);
|
||
|
|
if (
|
||
|
|
!['http:', 'https:'].includes(url.protocol) ||
|
||
|
|
url.pathname !== '/' ||
|
||
|
|
url.search ||
|
||
|
|
url.hash ||
|
||
|
|
url.username ||
|
||
|
|
url.password
|
||
|
|
)
|
||
|
|
throw new Error(
|
||
|
|
'SITE_BASE_URL/baseURL must be an HTTP(S) origin without a subpath, query, fragment, or credentials.',
|
||
|
|
);
|
||
|
|
return url;
|
||
|
|
}
|