I am currently working with an array of content in my JSON
that includes URLs
as plain text. My goal is to detect these text URLs and convert them into actual clickable links. However, I'm facing an issue where even though the URL is properly replaced with an <a>
tag containing the correct href=""
, it still appears as text and not as HTML on the page.
urlifyContent(){
let urlRegex =/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
for (let index = 0; index < this.message.Content.length; ++index){
this.message.Content[index] = this.message.Content[index].replace(urlRegex,`"<a href='$1'target='_blank'>$1</a>"`);
}
}