Skip to content

Commit

Permalink
fix: fix svg caching (#3471)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianthedev authored Nov 28, 2024
1 parent aa10071 commit 5a982a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/helpers/avo/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def svg(file_name, **args)

file_name = "#{file_name}.svg" unless file_name.end_with? ".svg"

Avo::CACHED_SVGS[file_name] ||= with_asset_finder(::Avo::SvgFinder) do
with_asset_finder(::Avo::SvgFinder) do
inline_svg file_name, **args
end
end
Expand Down
12 changes: 7 additions & 5 deletions lib/avo/svg_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ def initialize(filename)

# Use the default static finder logic. If that doesn't find anything, search according to our pattern:
def pathname
found_asset = default_strategy
Avo::CACHED_SVGS[@filename] ||= begin
found_asset = default_strategy

# Use the found asset
return found_asset if found_asset.present?
# Use the found asset
return found_asset if found_asset.present?

paths.find do |path|
File.exist? path
paths.find do |path|
File.exist? path
end
end
end

Expand Down

0 comments on commit 5a982a9

Please sign in to comment.