Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URI sig improvements #864

Merged
merged 2 commits into from
Feb 7, 2022
Merged
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
4 changes: 2 additions & 2 deletions stdlib/uri/0/generic.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ module URI
# uri.merge!("/main.rbx?page=1")
# uri.to_s # => "http://my.example.com/main.rbx?page=1"
#
def merge!: (string oth) -> String
def merge!: (URI::Generic | string oth) -> String

# <!--
# rdoc-file=lib/uri/generic.rb
Expand All @@ -904,7 +904,7 @@ module URI
# uri.merge("/main.rbx?page=1")
# # => "http://my.example.com/main.rbx?page=1"
#
def merge: (string oth) -> URI::Generic
def merge: (URI::Generic | string oth) -> URI::Generic

# :stopdoc:
def route_from_path: (String src, String dst) -> String
Expand Down
35 changes: 35 additions & 0 deletions stdlib/uri/0/http.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,41 @@ module URI
def self.build: (Array[String | Integer] args) -> URI::HTTP
| ({ userinfo: String, host: String, port: Integer, path: String, query: String, fragment: String }) -> URI::HTTP

# <!--
# rdoc-file=lib/uri/http.rb
# - authority()
# -->
# ## Description
#
# Returns the authority for an HTTP uri, as defined in
# https://datatracker.ietf.org/doc/html/rfc3986/#section-3.2.
#
# Example:
#
# URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').authority #=> "www.example.com"
# URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').authority #=> "www.example.com:8000"
# URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').authority #=> "www.example.com"
#
def authority: () -> String

# <!--
# rdoc-file=lib/uri/http.rb
# - origin()
# -->
# ## Description
#
# Returns the origin for an HTTP uri, as defined in
# https://datatracker.ietf.org/doc/html/rfc6454.
#
# Example:
#
# URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').origin #=> "http://www.example.com"
# URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').origin #=> "http://www.example.com:8000"
# URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').origin #=> "http://www.example.com"
# URI::HTTPS.build(host: 'www.example.com', path: '/foo/bar').origin #=> "https://www.example.com"
#
def origin: () -> String

# <!--
# rdoc-file=lib/uri/http.rb
# - request_uri()
Expand Down