0
0
Fork 0

Move lib/mastodon/premailer_webpack_strategy to lib/ (#27636)

This commit is contained in:
Matt Jankowski 2023-11-29 05:08:55 -05:00 committed by GitHub
parent 72b7cd349c
commit 31bef99b9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 2 deletions

View file

@ -0,0 +1,23 @@
# frozen_string_literal: true
module PremailerWebpackStrategy
def load(url)
asset_host = ENV['CDN_HOST'] || ENV['WEB_DOMAIN'] || ENV['LOCAL_DOMAIN']
if Webpacker.dev_server.running?
asset_host = "#{Webpacker.dev_server.protocol}://#{Webpacker.dev_server.host_with_port}"
url = File.join(asset_host, url)
end
css = if url.start_with?('http')
HTTP.get(url).to_s
else
url = url[1..] if url.start_with?('/')
Rails.public_path.join(url).read
end
css.gsub(%r{url\(/}, "url(#{asset_host}/")
end
module_function :load
end