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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t