Skip to content

Commit

Permalink
Fix custom path bug
Browse files Browse the repository at this point in the history
  • Loading branch information
justalever committed Aug 30, 2024
1 parent 850e220 commit 0b4182b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/railsui_icon/icon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ def render_standard_icon
def render_custom_path(custom_path)
return warning if custom_path.blank?

file_name = File.basename(URI.parse(custom_path).path)
asset_path = nil

if defined?(Railsui::Engine) && Railsui::Engine.root.present?
engine_asset_path = Railsui::Engine.root.join("app/assets/images#{custom_path}")
engine_asset_path = Railsui::Engine.root.join("app/assets/images", file_name)
asset_path = engine_asset_path if File.exist?(engine_asset_path)
end

unless asset_path
app_asset_path = Rails.root.join("app/assets/images#{custom_path}")
app_asset_path = Rails.root.join("app/assets/images", file_name)
asset_path = app_asset_path.to_s if File.exist?(app_asset_path)
end

Expand Down

0 comments on commit 0b4182b

Please sign in to comment.