Let's say that I have a string
string_with_url = 'Random text https://myurl.com'
Is it possible to wrap the url with an anchor tag and only make the wrapped text html safe?
Currently I have to do the following
def add_anchor(message)
url_regex = %r{(?:https?)://\S+}i
string_with_url.gsub url_regex, '<a href="\0" target="_blank">\0</a>'
render add_anchor(string_with_url).html_safe
Even though I am only adding the anchor tag here, I am forced to make the wrong string html safe.