Skip to content

Instantly share code, notes, and snippets.

@zzak
Created May 1, 2012 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zzak/2571731 to your computer and use it in GitHub Desktop.
Save zzak/2571731 to your computer and use it in GitHub Desktop.
# 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