Port 0923e2cb26d179f197680c978495593c8b205a80 to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
12 lines
227 B
TypeScript
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;
|
|
}
|
|
}
|