File tree Expand file tree Collapse file tree 2 files changed +1
-28
lines changed
lib/html_pipeline/node_filter
test/html_pipeline/node_filter Expand file tree Collapse file tree 2 files changed +1
-28
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,6 @@ def selector
2020 end
2121
2222 def handle_element ( element )
23- return unless asset_proxy_enabled?
24-
2523 original_src = element [ "src" ]
2624 return unless original_src
2725
@@ -51,9 +49,6 @@ class << self
5149 # all the necessary keys in the context. One example would be to override
5250 # this and pull the settings from a set of global application settings.
5351 def transform_context ( context , proxy_settings = { } )
54- context [ :asset_proxy_enabled ] = proxy_settings . fetch ( :enabled , true )
55- return context unless context [ :asset_proxy_enabled ]
56-
5752 context [ :asset_proxy ] = proxy_settings [ :url ] if proxy_settings [ :url ]
5853 context [ :asset_proxy_secret_key ] = proxy_settings [ :secret_key ] if proxy_settings [ :secret_key ]
5954
@@ -75,13 +70,7 @@ def determine_allowlist(proxy_settings)
7570 end
7671 end
7772
78- private
79-
80- def asset_proxy_enabled?
81- context [ :asset_proxy_enabled ]
82- end
83-
84- def asset_proxy_url ( url )
73+ private def asset_proxy_url ( url )
8574 "#{ context [ :asset_proxy ] } /#{ asset_url_hash ( url ) } /#{ hexencode ( url ) } "
8675 end
8776
Original file line number Diff line number Diff line change @@ -14,21 +14,6 @@ def image(path)
1414 %(<img src="#{ path } " />)
1515 end
1616
17- it "does not replace if disabled" do
18- settings = {
19- enabled : false ,
20- secret_key : "shared-secret" ,
21- url : "https://assets.example.com" ,
22- allowlist : [ "somewhere.com" , "*.mydomain.com" ] ,
23- }
24-
25- context = DESCRIBED_CLASS . transform_context ( { } , settings )
26- src = "http://example.com/test.png"
27- res = @filter . call ( image ( src ) , context : context )
28-
29- assert_equal ( image ( src ) , res )
30- end
31-
3217 describe "setting up the context" do
3318 it "#transform_context" do
3419 settings = {
@@ -40,7 +25,6 @@ def image(path)
4025
4126 context = DESCRIBED_CLASS . transform_context ( { } , settings )
4227
43- assert ( context [ :asset_proxy_enabled ] )
4428 assert_equal ( "shared-secret" , context [ :asset_proxy_secret_key ] )
4529 assert_equal ( "https://assets.example.com" , context [ :asset_proxy ] )
4630 assert_equal ( /^(somewhere\. com|.*?\. mydomain\. com)$/i , context [ :asset_proxy_domain_regexp ] )
You can’t perform that action at this time.
0 commit comments