1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/uri] Update file.rb

The module here is called `URI`, so it's probably reasonable to expect a requirement for the path to be RFC3986-compliant, but on the other hand, the class is called `File`, so it might be reasonable to expect that a path produced by e.g. the `File` class would be consumable by its `build` method (this fails if the filename contains e.g. a space).

https://github.com/ruby/uri/commit/ef79789b83
This commit is contained in:
Frank Schmitt 2022-02-15 15:48:09 -08:00 committed by git
parent 9f9a0940dd
commit 054ae999dc

View file

@ -33,6 +33,9 @@ module URI
# If an Array is used, the components must be passed in the
# order <code>[host, path]</code>.
#
# A path from e.g. the File class should be escaped before
# being passed.
#
# Examples:
#
# require 'uri'
@ -44,6 +47,9 @@ module URI
# :path => '/ruby/src'})
# uri2.to_s # => "file://host.example.com/ruby/src"
#
# uri3 = URI::File.build({:path => URI::escape('/path/my file.txt')})
# uri3.to_s # => "file:///path/my%20file.txt"
#
def self.build(args)
tmp = Util::make_components_hash(self, args)
super(tmp)