Skip to content

Instantly share code, notes, and snippets.

@maxlapshin
Created August 23, 2009 08:09
Show Gist options
  • Save maxlapshin/173200 to your computer and use it in GitHub Desktop.
Save maxlapshin/173200 to your computer and use it in GitHub Desktop.
module URI
def self.parse(uri)
uri = "#{uri}/" unless uri.index("/")
uri = "http://#{uri}" unless uri.index("://")
scheme, userinfo, host, port,
registry, path, opaque, query, fragment = self.split(uri)
if scheme && @@schemes.include?(scheme.upcase)
@@schemes[scheme.upcase].new(scheme, userinfo, host, port,
registry, path, opaque, query,
fragment)
else
HTTP.new(scheme, userinfo, host, port,
registry, path, opaque, query,
fragment).normalize
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment