Currently, the URL is inserted along with other text in drafts.content
I’ll try to figure out how to extract the URLs from the content as from my understanding, I need to pass just the URL string for your solutions to work?
Looks like you’ve found a good solution – a footnote on posting code: you can make it more legible by fencing above and below with three backticks ``` to enable syntax highlighting.
```
// Regex to strip URLs of any query parameters
const urlRegex = /((https?://)(([^:/?#])(?::([0-9]+))?)([/]{0,1}[^?#])(?[^#]|)(#.|))/i;
// define replacement expression…
const replaceWith = “<a href=”$2$4$6">$2$4$6";
// do the replacement…
draft.content = draft.content.replace(urlRegex, replaceWith);
draft.update();