kubarskii / cs50-final

2 stars 1 forks source link

[NEXT] Wrap links in text [?WS] #34

Open kubarskii opened 1 year ago

kubarskii commented 1 year ago

When message contains link, chat should automatically wrap it into

<a href="<link from the message>">Link from the message</a>

Possible solution for finding links:

const re = /([^\"=]{2}|^)((https?|ftp):\/\/\S+[^\s.,> )\];'\"!?])/; 
const subst = '$1<a href="$2" target="_blank">$2</a>'; 
const withlink = textownstr.replace(re, subst);