Skip to content

Commit bed2010

Browse files
committed
Fail fast if asset proxy is disabled
1 parent ee8724c commit bed2010

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/html/pipeline/camo_filter.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ class CamoFilter < Filter
2020
# Hijacks images in the markup provided, replacing them with URLs that
2121
# go through the github asset proxy.
2222
def call
23+
return unless asset_proxy_enabled?
24+
2325
doc.search("img").each do |element|
24-
next if context[:disable_asset_proxy]
2526
next if element['src'].nil?
2627

2728
begin
@@ -55,6 +56,11 @@ def asset_url_hash(url)
5556
OpenSSL::HMAC.hexdigest(digest, asset_proxy_secret_key, url)
5657
end
5758

59+
# Private: Return true if asset proxy filter should be enabled
60+
def asset_proxy_enabled?
61+
!context[:disable_asset_proxy]
62+
end
63+
5864
# Private: the hostname to use for generated asset proxied URLs.
5965
def asset_proxy_host
6066
context[:asset_proxy]

0 commit comments

Comments
 (0)