1 // eslint-disable-next-line no-useless-escape
2 const URL_REGEX = /(\b(?:https|ftps|file|mailto|tel|sms):(?:(?!["<>\^`{|}])\S)+)/gi;
3 const A_TAG_REGEX = /(<a[^>]+>.+?<\/a>)/gi;
5 const urlify = (string: string) =>
9 if (piece.match(A_TAG_REGEX)) {
13 return piece.replace(URL_REGEX, '<a href="$1">$1</a>');
17 export default urlify;