Files
Mastodon/app/javascript/flavours/glitch/utils/checks.ts
T
2026-02-03 16:04:00 +01:00

12 lines
227 B
TypeScript

export function isValidUrl(
url: string,
allowedProtocols = ['https:'],
): boolean {
try {
const parsedUrl = new URL(url);
return allowedProtocols.includes(parsedUrl.protocol);
} catch {
return false;
}
}