Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def normalize_uri(uri_or_options)
- if String === uri_or_options
- uri_or_options = Addressable::URI.parse(uri_or_options)
- end
- if Addressable::URI === uri_or_options
- return uri_or_options.normalize
- end
- adapter = uri_or_options.delete(:adapter)
- user = uri_or_options.delete(:username)
- password = uri_or_options.delete(:password)
- host = (uri_or_options.delete(:host) || "")
- port = uri_or_options.delete(:port)
- database = uri_or_options.delete(:database)
- query = uri_or_options.to_a.map { |pair| pair.join('=') }.join('&')
- query = nil if query == ""
- return Addressable::URI.new(
- adapter, user, password, host, port, database, query, nil
- )
- end
Add Comment
Please, Sign In to add comment