gnoxnahte_obsidian-auto-embed/utility.ts
GnoxNahte db45c00a7e Completed asking user if they want to add embeds after pasting url (Code cleanup needed)
- User pastes url
- Plugin suggests to embed (has an option to cancel or tap anywhere else to cancel)
- After accepting to embed, mark the link for embedding [ae:embed](link)
2024-03-09 10:18:47 +08:00

10 lines
No EOL
382 B
TypeScript

export const regexUrl = /(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/gi
export function isURL(str: string) : boolean {
try {
new URL(str);
return true;
} catch {
return false;
}
}