Skip to content

Commit

Permalink
Fix Stimpack::Packs.find by returning the Pack
Browse files Browse the repository at this point in the history
There was a sutble bug where the method was returning a path to the
Pack. The original intention has always been to return the Pack.
  • Loading branch information
ngan committed Dec 8, 2022
1 parent 5567768 commit 6f79f14
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/stimpack/packs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ def root
def find(path)
@find_pack_paths ||= all_by_path.keys.sort_by(&:length).reverse!.map { |path| "#{path}/" }
path = "#{path}/"
@find_pack_paths.find do |pack_path|
matched_path = @find_pack_paths.find do |pack_path|
path.start_with?(pack_path)
end
all_by_path.fetch(matched_path.chomp("/")) if matched_path
end

def all(parent = nil)
Expand Down

0 comments on commit 6f79f14

Please sign in to comment.