diff --git a/lib/bootsnap/load_path_cache/cache.rb b/lib/bootsnap/load_path_cache/cache.rb index 837b72b2..12339da7 100644 --- a/lib/bootsnap/load_path_cache/cache.rb +++ b/lib/bootsnap/load_path_cache/cache.rb @@ -50,7 +50,7 @@ def find(feature, try_extensions: true) return feature if absolute_path?(feature) - if feature.start_with?('./') + if feature.start_with?('./') || feature.start_with?('../') return try_extensions ? expand_path(feature) : File.expand_path(feature).freeze end diff --git a/test/load_path_cache/cache_test.rb b/test/load_path_cache/cache_test.rb index bd862605..9b3a2c3b 100644 --- a/test/load_path_cache/cache_test.rb +++ b/test/load_path_cache/cache_test.rb @@ -58,9 +58,12 @@ def test_simple def test_extension_append_for_relative_paths po = [@dir1] cache = Cache.new(NullCache, po) + dir1_basename = File.basename(@dir1) Dir.chdir(@dir1) do assert_equal("#{@dir1}/a.rb", cache.find('./a')) assert_equal("#{@dir1}/a", cache.find('./a', try_extensions: false)) + assert_equal("#{@dir1}/a.rb", cache.find("../#{dir1_basename}/a")) + assert_equal("#{@dir1}/a", cache.find("../#{dir1_basename}/a", try_extensions: false)) assert_equal("#{@dir1}/dl#{DLEXT}", cache.find('./dl')) assert_equal("#{@dir1}/dl", cache.find('./dl', try_extensions: false)) assert_equal("#{@dir1}/enoent", cache.find('./enoent'))