fix: sanitize public provenance links

This commit is contained in:
ik committed 2026-09-21 18:26:38 +07:00
1 parent f3eb54083f
commit 11e54a7842
6 files changed
+29 -4

No files matched your search

+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;
}
}