Skip to content

Commit ef79789

Browse files
authored
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).
1 parent 230fd18 commit ef79789

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/uri/file.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class File < Generic
3333
# If an Array is used, the components must be passed in the
3434
# order <code>[host, path]</code>.
3535
#
36+
# A path from e.g. the File class should be escaped before
37+
# being passed.
38+
#
3639
# Examples:
3740
#
3841
# require 'uri'
@@ -44,6 +47,9 @@ class File < Generic
4447
# :path => '/ruby/src'})
4548
# uri2.to_s # => "file://host.example.com/ruby/src"
4649
#
50+
# uri3 = URI::File.build({:path => URI::escape('/path/my file.txt')})
51+
# uri3.to_s # => "file:///path/my%20file.txt"
52+
#
4753
def self.build(args)
4854
tmp = Util::make_components_hash(self, args)
4955
super(tmp)

0 commit comments

Comments
 (0)