22 lines · 527 B · TypeScript
RawDownload
export function normalizeSecureRelayUrl(value: string): string | null {  try {    const url = new URL(value.trim());    if (      url.protocol !== "https:" ||      url.username.length > 0 ||      url.password.length > 0 ||      url.search.length > 0 ||      url.hash.length > 0 ||      !/^\/+$/u.test(url.pathname)    ) {      return null;    }    return url.origin;  } catch {    return null;  }} export function isSecureRelayUrl(value: string): boolean {  return normalizeSecureRelayUrl(value) !== null;}