mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 09:36:08 +00:00
feat(bunny-cdn): refactor CDN hostname resolution and update asset URLs for improved flexibility
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
function normalizeBunnyCdnHostname(raw: string | null | undefined): string | null {
|
||||
if (!raw) return null;
|
||||
const trimmed = raw.trim();
|
||||
if (!trimmed) return null;
|
||||
|
||||
try {
|
||||
const parsed = new URL(trimmed);
|
||||
return parsed.hostname || null;
|
||||
} catch {
|
||||
return trimmed.replace(/^https?:\/\//, '').replace(/\/+$/, '') || null;
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveServerBunnyCdnHostname(): string | null {
|
||||
return normalizeBunnyCdnHostname(process.env.BUNNY_CDN_URL || process.env.NEXT_PUBLIC_BUNNY_CDN_URL);
|
||||
}
|
||||
|
||||
export function resolvePublicBunnyCdnHostname(): string | null {
|
||||
return normalizeBunnyCdnHostname(process.env.NEXT_PUBLIC_BUNNY_CDN_URL);
|
||||
}
|
||||
Reference in New Issue
Block a user