Skip to content

Commit f27de44

Browse files
committed
Update patch feature finding to prefer the longest matching load path
1 parent 3d56e7a commit f27de44

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Bug fixes:
1111
* Raise `RangeError` for `Time.at(bignum)` (#2580, @eregon).
1212
* Fix `Integer#{<<,>>}` with RHS bignum and long (@eregon).
1313
* Fix a resource leak from allocators defined in C extensions (@aardvark179).
14+
* Update patch feature finding to prefer the longest matching load path (#2605, @bjfish).
1415

1516
Compatibility:
1617

src/main/ruby/truffleruby/core/truffle/feature_loader.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,11 @@ def self.provide_feature(feature)
219219
end
220220

221221
def self.relative_feature(expanded_path)
222-
load_path_entry = get_expanded_load_path.find do |load_dir|
222+
load_path_entries = get_expanded_load_path.select do |load_dir|
223223
expanded_path.start_with?(load_dir) and expanded_path[load_dir.size] == '/'
224224
end
225-
if load_path_entry
225+
if !load_path_entries.empty?
226+
load_path_entry = load_path_entries.max_by(&:length)
226227
before_dot_rb = expanded_path.end_with?('.rb') ? -4 : -1
227228
expanded_path[load_path_entry.size+1..before_dot_rb]
228229
else

0 commit comments

Comments
 (0)