I'm trying to parse a URI from user input. I'm assuming some users won't put the scheme in their URI's and I wan't to default to "http"
I wrote the following code which I thought should work. But it dosen't.
require 'uri'
uri_to_check = URI::parse("www.google.com")
uri_to_check.scheme = "http" unless uri_to_check.scheme
puts uri_to_check.to_s
I expect to see "http://www.google.com" but I get "http:www.google.com". Is it even possible to do it this way?
If so, what am I missing?
Is there a better way to do this?