class Bundler::URI::Generic
def merge(oth)
# => "http://my.example.com/main.rbx?page=1"
uri.merge("/main.rbx?page=1")
uri = Bundler::URI.parse("http://my.example.com")
require 'bundler/vendor/uri/lib/uri'
== Usage
Merges two URIs.
== Description
Bundler::URI or String
+oth+::
== Args
def merge(oth) rel = parser.__send__(:convert_to_uri, oth) if rel.absolute? #raise BadURIError, "both Bundler::URI are absolute" if absolute? # hmm... should return oth for usability? return rel end unless self.absolute? raise BadURIError, "both Bundler::URI are relative" end base = self.dup authority = rel.userinfo || rel.host || rel.port # RFC2396, Section 5.2, 2) if (rel.path.nil? || rel.path.empty?) && !authority && !rel.query base.fragment=(rel.fragment) if rel.fragment return base end base.query = nil base.fragment=(nil) # RFC2396, Section 5.2, 4) if !authority base.set_path(merge_path(base.path, rel.path)) if base.path && rel.path else # RFC2396, Section 5.2, 4) base.set_path(rel.path) if rel.path end # RFC2396, Section 5.2, 7) base.set_userinfo(rel.userinfo) if rel.userinfo base.set_host(rel.host) if rel.host base.set_port(rel.port) if rel.port base.query = rel.query if rel.query base.fragment=(rel.fragment) if rel.fragment return base end # merge