End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
URI::Generic#route_from
route_from(oth)
lib/uri/generic.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.2.0/lib/uri/generic.rb, line 1262
def route_from(oth)
# you can modify `rel', but can not `oth'.
begin
oth, rel = route_from0(oth)
rescue
raise $!.class, $!.message
end
if oth == rel
return rel
end
rel.set_path(route_from_path(oth.path, self.path))
if rel.path == './' && self.query
# "./?foo" -> "?foo"
rel.set_path('')
end
return rel
end
Args
Description
Calculates relative path from oth to self.
Usage
Example
require 'uri' uri = URI.parse('http://my.example.com/main.rbx?page=1') uri.route_from('http://my.example.com') #=> #<URI::Generic /main.rbx?page=1>