method
route_from0
v1_8_7_72 -
Show latest stable
-
0 notes -
Class: URI::Generic
- 1_8_6_287 (0)
- 1_8_7_72 (0)
- 1_8_7_330 (0)
- 1_9_1_378 (0)
- 1_9_2_180 (0)
- 1_9_3_125
- 1_9_3_392
- 2_1_10
- 2_2_9
- 2_4_6
- 2_5_5
- 2_6_3
- What's this?
route_from0(oth)
private
Hide source
# File lib/uri/generic.rb, line 842 def route_from0(oth) case oth when Generic when String oth = URI.parse(oth) else raise ArgumentError, "bad argument(expected URI object or URI string)" end if self.relative? raise BadURIError, "relative URI: #{self}" end if oth.relative? raise BadURIError, "relative URI: #{oth}" end if self.scheme != oth.scheme return self, self.dup end rel = URI::Generic.new(nil, # it is relative URI self.userinfo, self.host, self.port, self.registry, self.path, self.opaque, self.query, self.fragment) if rel.userinfo != oth.userinfo || rel.host.to_s.downcase != oth.host.to_s.downcase || rel.port != oth.port if self.userinfo.nil? && self.host.nil? return self, self.dup end rel.set_port(nil) if rel.port == oth.default_port return rel, rel end rel.set_userinfo(nil) rel.set_host(nil) rel.set_port(nil) if rel.path && rel.path == oth.path rel.set_path('') rel.set_query(nil) if rel.query == oth.query return rel, rel elsif rel.opaque && rel.opaque == oth.opaque rel.set_opaque('') rel.set_query(nil) if rel.query == oth.query return rel, rel end # you can modify `rel', but can not `oth'. return oth, rel end