GoonCord/utils/isValidHttpUrl.ts

13 lines
275 B
TypeScript
Raw Normal View History

2025-12-10 17:20:21 +01:00
// https://stackoverflow.com/a/43467144/15031462
export default function isValidHttpUrl(input: string) {
let url: URL;
try {
url = new URL(input);
} catch {
return false;
}
return url.protocol === "http:" || url.protocol === "https:";
}