mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-09-14 17:42:17 +00:00
fix: harden review findings and Netlify install
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
const LOOPBACK_HOSTS = new Set(['127.0.0.1', 'localhost', '[::1]']);
|
||||
|
||||
export function isLoopbackUrl(value: string): boolean {
|
||||
try {
|
||||
return LOOPBACK_HOSTS.has(new URL(value).hostname);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function requireLoopbackUrl(value: string, label: string): string {
|
||||
if (!isLoopbackUrl(value))
|
||||
throw new Error(`Refusing to send credentials to non-loopback ${label}`);
|
||||
return value;
|
||||
}
|
||||
Reference in New Issue
Block a user