Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

@imperator

View uri_parse_invalid_uri.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# Fix uri's with only 1 '/' in them
require 'uri'
 
module URI
class << self
alias parse_orig parse
 
def parse(string)
unless string.include?("//")
string[string.index('/')] = "//" if string.include?("http")
end
parse_orig(string)
end
end
end
 
uri = URI.parse('http:/www.google.com')
p uri.host # => www.google.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.