fix: sanitize public provenance links

This commit is contained in:
ik
2026-09-21 18:26:38 +07:00
parent f3eb54083f
commit 11e54a7842
6 changed files with 29 additions and 4 deletions
+10
View File
@@ -0,0 +1,10 @@
export function safeHttpUrl(value: string | null | undefined): string | null {
if (!value) return null;
try {
const url = new URL(value);
if ((url.protocol !== "http:" && url.protocol !== "https:") || url.username || url.password || !url.hostname) return null;
return url.href;
} catch {
return null;
}
}