app/models/blacklight/icon.rb in blacklight-7.25.1 vs app/models/blacklight/icon.rb in blacklight-7.25.2

- old
+ new

@@ -53,11 +53,14 @@ ## # @return [String] def file_source raise Blacklight::Exceptions::IconNotFound, "Could not find #{path}" if file.blank? - file.source.force_encoding('UTF-8') + # Handle both Sprockets::Asset and Propshaft::Asset + data = file.respond_to?(:source) ? file.source : file.path.read + + data.force_encoding('UTF-8') end def ng_xml @ng_xml ||= Nokogiri::XML(file_source).remove_namespaces! end @@ -66,10 +69,13 @@ def icon_name_context [icon_name, additional_options[:label_context]].compact.join('_') end + # @return [Sprockets::Asset,Propshaft::Asset] def file + return Rails.application.assets.load_path.find(path) if defined? Propshaft + # Rails.application.assets is `nil` in production mode (where compile assets is enabled). # This workaround is based off of this comment: https://github.com/fphilipe/premailer-rails/issues/145#issuecomment-225992564 (Rails.application.assets || ::Sprockets::Railtie.build_environment(Rails.application)).find_asset(path) end