mirror of
https://github.com/muerwre/vk-tg-bot.git
synced 2025-04-26 07:26:41 +07:00
fix url extraction
This commit is contained in:
parent
96fea09b3f
commit
6b0b0b9b57
2 changed files with 22 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
import { URL } from "url";
|
||||
|
||||
const urlRe = /(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,})/gim;
|
||||
const urlRe = /(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,})/gim;
|
||||
|
||||
export const extractURLs = (text: string): URL[] => {
|
||||
const matches = text.match(urlRe) || [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue