Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1x 7x 2x 5x 5x 5x 2x 3x | const ALLOWED_EXTERNAL_PROTOCOLS = new Set(['http:', 'https:', 'mailto:', 'tel:']);
export function getSafeExternalUrl(url: string | null | undefined): string | null {
if (!url || typeof url !== 'string') {
return null;
}
try {
const parsed = new URL(url, window.location.origin);
if (!ALLOWED_EXTERNAL_PROTOCOLS.has(parsed.protocol)) {
return null;
}
return parsed.toString();
} catch {
return null;
}
}
|