Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added new method to check if path starts with media or add it #100

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/inline_svg/webpack_asset_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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