Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize relative ../ paths resolution #373

Merged
merged 1 commit into from Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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