Skip to content

Commit

Permalink
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/src/main/java/org/jruby/RubyFile.java
Original file line number Diff line number Diff line change
@@ -1654,8 +1654,9 @@ private static IRubyObject expandPathInternal(ThreadContext context, IRubyObject
// argument is relative.
if (args.length == 2 && !args[1].isNil()) {
// TODO maybe combine this with get_path method
if ((args[1] instanceof RubyString) && args[1].asJavaString().startsWith("uri:")) {
cwd = args[1].asJavaString();
String path = args[1].toString();
if (path.startsWith("uri:")) {
cwd = path;
} else {
cwd = StringSupport.checkEmbeddedNulls(runtime, get_path(context, args[1])).getUnicodeValue();

6 changes: 6 additions & 0 deletions test/test_file.rb
Original file line number Diff line number Diff line change
@@ -325,6 +325,12 @@ def test_expand_path_with_file_url_relative_path
assert_equal "file:#{Dir.pwd}/foo/bar", File.expand_path("file:foo/bar")
end

# GH-3150
def test_expand_path_with_pathname_and_uri_path
jruby_specific_test
assert_equal 'uri:classloader://foo', File.expand_path('foo', Pathname.new('uri:classloader:/'))
end

# JRUBY-5219
def test_expand_path_looks_like_url
jruby_specific_test

0 comments on commit 0832a7c

Please sign in to comment.