Skip to content

Commit

Permalink
stdlib: Update type for URI.join
Browse files Browse the repository at this point in the history
URI.join takes not only strings, but also URI objects.  Therefore it
would be better to update its signature.

Internally, arguments will be converted to URI objects before
concatenating.
https://github.com/ruby/ruby/blob/v3_2_2/lib/uri/rfc3986_parser.rb#L107-L116
  • Loading branch information
tk0miya committed Oct 22, 2023
1 parent da068cb commit 7b690fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stdlib/uri/0/common.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ module URI
# URI.join('http://example.com', '/foo/', 'bar')
# # => #<URI::HTTP http://example.com/foo/bar>
#
def self.join: (String str, *String strs) -> URI::Generic
def self.join: (_ToStr | URI::Generic str, *_ToStr | URI::Generic strs) -> URI::Generic

# <!--
# rdoc-file=lib/uri/common.rb
Expand Down
2 changes: 2 additions & 0 deletions test/stdlib/URI_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def test_join
URI, :join, "http://example.com"
assert_send_type "(String, String) -> URI::Generic",
URI, :join, "http://example.com", "foo"
assert_send_type "(URI::Generic, URI::Generic) -> URI::Generic",
URI, :join, URI("http://example.com"), URI("foo")
end

def test_parse
Expand Down

0 comments on commit 7b690fa

Please sign in to comment.