I have a linkify url text which is in chat message which O needs to allow even <x x>
after a valid url. Now when I am using any string after url, it ends up with
InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('x<') is not a valid name.
This should allow
- before & after strings Ex: Hi this is test page https://www.test.com as well
Code
sendUrlText(e) {
if (e && e.keyCode && e.keyCode !== 13) return;
var stateMessage = unescape(this.state.message);
function linkify(stateMessage){
return stateMessage.replace(/(https?:\/\/[^\s]+)/g, "<a href='$1' target='_blank'>$1</a>")
}
var formattedMessage = linkify(stateMessage);
}
Any suggestion how can I allow /< x x >
after url and turns it into
For example:
with a linkify url.