G
YouTube TikTok Games
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/uri/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,7 @@ def route_from0(oth)
"relative URI: #{oth}"
end

if self.scheme != oth.scheme
if self.scheme != oth.scheme || self.hierarchical? != oth.hierarchical?
return self, self.dup
end
rel = URI::Generic.new(nil, # it is relative URI
Expand Down
12 changes: 12 additions & 0 deletions test/uri/test_generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,18 @@ def test_route

url = URI.parse('mailto:foo@example.com').route_to('mailto:foo@example.com')
assert_equal('', url.to_s)

url = URI.parse('file:notes.txt').route_to('file:/home/alice/notes.txt')
assert_equal('file:///home/alice/notes.txt', url.to_s)

url = URI.parse('file:/home/alice/notes.txt').route_to('file:notes.txt')
assert_equal('file:notes.txt', url.to_s)

url = URI.parse('file:notes.txt').route_to('file:/home/alice/../bob/notes.txt')
assert_equal('file:///home/alice/../bob/notes.txt', url.to_s)

url = URI.parse('http:example.com').route_to('http://example.com/about')
assert_equal('http://example.com/about', url.to_s)
end

def test_rfc3986_examples
Expand Down