1export function normalizeSecureRelayUrl(value: string): string | null {
2 try {
3 const url = new URL(value.trim());
4 if (
5 url.protocol !== "https:" ||
6 url.username.length > 0 ||
7 url.password.length > 0 ||
8 url.search.length > 0 ||
9 url.hash.length > 0 ||
10 !/^\/+$/u.test(url.pathname)
11 ) {
12 return null;
13 }
14 return url.origin;
15 } catch {
16 return null;
17 }
18}
19
20export function isSecureRelayUrl(value: string): boolean {
21 return normalizeSecureRelayUrl(value) !== null;
22}