I have this:
function linkify(text) {
var urlRegex =/(https?://[^s]+)/g;
return text.replace(urlRegex, function(url) {
return '<a href="' + url + '">' + url + '</a>';
});
}
when I try this function like this:
console.log(linkify("https://music.youtube.com/watch?v=rM4_leT8ZFU&si=Gy16TSfzwbENshHZ"));
I get this:
<a href="<a href="https://music.youtube.com/watch?v=rM4_leT8ZFU&si=Gy16TSfzwbENshHZ">https://music.youtube.com/watch?v=rM4_leT8ZFU&si=Gy16TSfzwbENshHZ</a>"><a href="https://music.youtube.com/watch?v=rM4_leT8ZFU&si=Gy16TSfzwbENshHZ">https://music.youtube.com/watch?v=rM4_leT8ZFU&si=Gy16TSfzwbENshHZ</a></a>
so the subdomains may be:
www or music or any other