Feature #14035
closedURI module always serializes to the minimal form insted of the traditional one
Description
Reproduce¶
execute URI("file:///etc/hosts").to_s
I expect¶
-
URI("file:///etc/hosts").to_s == "file:///etc/hosts"
-
URI to preserve traditional form instead converting it to the minimal one (Eg. see https://tools.ietf.org/html/rfc8089#appendix-B )
I wish¶
- URI to preserve the minimal/traditional form.
URI("file:///etc/hosts").to_s == "file:///etc/hosts"
URI("file:/etc/hosts").to_s == "file:/etc/hosts"
Instead¶
-
URI("file:///etc/hosts").to_s == "file:/etc/hosts"
-
URI("file:///etc/hosts").host == nil
Proposal for Ruby 2.4¶
Adopting the convention of an "empty host" instead of no authority when the passed string has the traditional form.
- file schema to have a blank/empty "" host
suggested in rfc3986 will fix the issue.
If the URI scheme defines a default for host, then that default
applies when the host subcomponent is undefined or when the
registered name is empty (zero length). For example, the "file" URI
scheme is defined so that no authority, an empty host, and
"localhost" all mean the end-user's machine, whereas the "http"
scheme considers a missing authority or empty host invalid.
Updated by ioggstream (Roberto Polli) about 7 years ago
- Subject changed from URI module file representation does not conform to the standard to URI module file representation uses the minimal form instead of the traditional one.
Updated by phluid61 (Matthew Kerwin) about 7 years ago
The spec for file URIs is RFC8089, which allows for file URIs with no authority part (e.g. 'file:/foo').
Neither it nor RFC3986 make any claims about canonical representation of URIs, much as I may have liked it to.
Also, have a look at the 'file-uri' gem.
Updated by ioggstream (Roberto Polli) about 7 years ago
- Tracker changed from Bug to Feature
- Subject changed from URI module file representation uses the minimal form instead of the traditional one. to URI module always serializes to the minimal form insted of the traditional one
- Description updated (diff)
- ruby -v deleted (
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]) - Backport deleted (
2.3: UNKNOWN, 2.4: UNKNOWN)
Updated by ioggstream (Roberto Polli) about 7 years ago
Hi Matthew, and thanks for your time!
phluid61 (Matthew Kerwin) wrote:
The spec for file URIs is RFC8089, which allows for file URIs with no authority part (e.g. 'file:/foo').
Ok.
Neither it nor RFC3986 make any claims about canonical representation of URIs, much as I may have liked it to.
I read here https://tools.ietf.org/html/rfc8089#appendix-B reports that there is a traditional
form though.
Clearly traditional
!= canonical
;)
Checked gem, thx++
Updated by naruse (Yui NARUSE) over 6 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r62767.
Introduce URI::File to handle file URI scheme
- the default value of URI::File's authority is "" (localhost).
Both nil and "localhost" is normalized to "" by default. - URI::File ignores setting userinfo and port
[Feature #14035]
fix https://github.com/ruby/ruby/pull/1719
fic https://github.com/ruby/ruby/pull/1832
Updated by naruse (Yui NARUSE) almost 4 years ago
- Related to Feature #15861: Correctly parse `file:c:/path/to/file` URIs added