Using this way you can solve your problem, If there is no http or https in the url.
def add_url_protocol(url)
!(url[/\Ahttp:\/\//] || url[/\Ahttps:\/\//]) ? "http://#{url}" : url
end
def add_url_protocol(url)
!(url[/\Ahttp:\/\//] || url[/\Ahttps:\/\//]) ? "http://#{url}" : url
end
No comments:
Post a Comment