From f077ada84c2c331661290f49197b663bfe2cccd3 Mon Sep 17 00:00:00 2001 From: damjack Date: Fri, 19 Jul 2019 11:27:11 +0200 Subject: [PATCH] Added new method to check if path start with media or add it --- lib/inline_svg/webpack_asset_finder.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/inline_svg/webpack_asset_finder.rb b/lib/inline_svg/webpack_asset_finder.rb index 8c74b96..263e310 100644 --- a/lib/inline_svg/webpack_asset_finder.rb +++ b/lib/inline_svg/webpack_asset_finder.rb @@ -10,10 +10,19 @@ def initialize(filename) def pathname public_path = Webpacker.config.public_path - file_path = Webpacker.instance.manifest.lookup(@filename) + file_path = resolve_path_to(@filename) return unless public_path && file_path File.join(public_path, file_path) end + + private + + def resolve_path_to(name) + path = name.starts_with?("media/") ? name : "media/#{name}" + Webpacker.instance.manifest.lookup(path) + rescue + Webpacker.instance.manifest.lookup(name) + end end end