RDT formatted cell: URL does not work because it includes the highlighting tags


#1

Hi community, I am using a formatter to render URLs in a RDT column. We also use the search component and when it highlights hits on that column, the URL does not work because it includes the highglighting tags. How can I get rid of them. My formatter looks like this:

const formatter = {
	fields: ["key", "epic_key"],
	format: function(field, value) {
		return { value: `<div><a href=\"https://some.domain.com/browse/${value}" target=new> ${value}</a></div>` };
	}
};

Any help on this will be appreciated.


#2

Hi @jonathan, thanks for reaching out. In order to achieve that you need to modify your function a little bit. Try with the one below that removes the highlighting tags when they exist.

const formatter = {
	fields: ["key", "epic_key"],

    format: function(field, value) {
		const regex = /(<([^>]+)>)/ig;
		let result = value.replace(regex, "");
		return { value: `<div><a href=\"https://some.domain.com/browse/${result}" target=new> ${value}</a></div>` };
    }
};

Give it a try and tell me how it went.


#3

Awesome, that works like a champ! Thanks @juan.dominguez!