Add http to URL it it is not present there

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

About the author

Being the CEO and Founder of ClecoTech International, Mr. Ashish Prajapati is dedicated towards his aim of mentoring young startups into a full-fledged businesses. He is helping startups from America, Europe, India, and various other countries through proper guidance and the use of latest technologies to develop their innovation and ideas into definite realities.

Leave a Reply

Your email address will not be published. Required fields are marked *