Skip to content
Open
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
7 changes: 1 addition & 6 deletions lib/uri/ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,8 @@ def self.build(args)
# foo/bar /foo/bar
# /foo/bar /%2Ffoo/bar
#
if args.kind_of?(Array)
args[3] = '/' + args[3].sub(/^\//, '%2F')
else
args[:path] = '/' + args[:path].sub(/^\//, '%2F')
end

tmp = Util::make_components_hash(self, args)
tmp[:path] = '/' + tmp[:path].sub(/^\//, '%2F')

if tmp[:typecode]
if tmp[:typecode].size == 1
Expand Down
13 changes: 13 additions & 0 deletions test/uri/test_ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ class URI::TestFTP < Test::Unit::TestCase
def setup
end


def test_build_does_not_mutate_components
components = {host: "example.test", path: "/folder"}
original = components.dup

first = URI::FTP.build(components)
second = URI::FTP.build(components)

assert_equal(original, components)
assert_equal(first, second)
assert_nothing_raised { URI::FTP.build(components.freeze) }
end

def test_parse
url = URI.parse('ftp://user:pass@host.com/abc/def')
assert_kind_of(URI::FTP, url)
Expand Down