Files
outline/shared/editor/lib/isUrl.ts
2022-01-19 18:43:15 -08:00

13 lines
208 B
TypeScript

export default function isUrl(text: string) {
if (text.match(/\n/)) {
return false;
}
try {
const url = new URL(text);
return url.hostname !== "";
} catch (err) {
return false;
}
}