Skip to content

Commit

Permalink
Merge pull request #373 from ojab/optimize_upper_dir_relative_paths
Browse files Browse the repository at this point in the history
Optimize relative `../` paths resolution
  • Loading branch information
casperisfine committed Sep 23, 2021
2 parents 89b1e97 + 2715ef6 commit e1882c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bootsnap/load_path_cache/cache.rb
Expand Up @@ -50,7 +50,7 @@ def find(feature, try_extensions: true)

return feature if absolute_path?(feature)

if feature.start_with?('./')
if feature.start_with?('./', '../')
return try_extensions ? expand_path(feature) : File.expand_path(feature).freeze
end

Expand Down
3 changes: 3 additions & 0 deletions test/load_path_cache/cache_test.rb
Expand Up @@ -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'))
Expand Down

0 comments on commit e1882c5

Please sign in to comment.