Ruby 3.3 リファレンスマニュアル

instance method URI::Generic#route_to

route_to(dst) -> URI::Generic[permalink][rdoc][edit]

自身から dst への相対パスを返します。

[PARAM] dst:
URI を文字列かURIオブジェクトで与えます。
require 'uri'
p URI.parse('http://example.com/').route_to('http://example.com/foo/bar.html')
  
#=> #<URI::Generic:0x20100198 URL:foo/bar.html>