Files
extension/src/utils/domains.ts
2024-01-10 19:27:20 +01:00

10 lines
232 B
TypeScript

export function makeUrlIntoDomain(url: string): string | null {
try {
const u = new URL(url);
if (!['http:', 'https:'].includes(u.protocol)) return null;
return u.host.toLowerCase();
} catch {
return null;
}
}