summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Schmitt <frank@frankschmitt.org>2022-02-15 15:48:09 -0800
committergit <svn-admin@ruby-lang.org>2022-05-12 10:06:57 +0900
commit054ae999dc5dfcb182f407bffceec5a52ae7ff6c (patch)
tree60eea099d3426a3daa11b7a4ae853dc28137888c
parent9f9a0940ddd6dd9cec03a9e13c543cea14f8d38a (diff)
[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
-rw-r--r--lib/uri/file.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/uri/file.rb b/lib/uri/file.rb
index 7671ad6470..4ff0bc097e 100644
--- a/lib/uri/file.rb
+++ b/lib/uri/file.rb
@@ -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)