File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,11 @@ class CamoFilter < Filter
21
21
def call
22
22
doc . search ( "img" ) . each do |element |
23
23
next if element [ 'src' ] . nil?
24
+ next if context [ :disable_asset_proxy ]
25
+
24
26
src = element [ 'src' ] . strip
25
- src = src . sub ( %r!^http://github.com! , ' https://github.com' )
27
+ next if src . match ( %r!^https://( \w + \. )? github(app)? .com! )
26
28
27
- next if context [ :disable_asset_proxy ]
28
29
element [ 'src' ] = asset_proxy_url ( src )
29
30
end
30
31
doc
Original file line number Diff line number Diff line change @@ -18,12 +18,24 @@ def test_camouflaging_http_image_urls
18
18
CamoFilter . call ( orig , @options ) . to_s
19
19
end
20
20
21
- def test_rewrites_dotcom_image_urls
22
- orig = %(<p><img src="http ://github.com/img.png"></p>)
21
+ def test_doesnt_rewrite_dotcom_image_urls
22
+ orig = %(<p><img src="https ://github.com/img.png"></p>)
23
23
assert_equal "<p><img src=\" https://github.com/img.png\" ></p>" ,
24
24
CamoFilter . call ( orig , @options ) . to_s
25
25
end
26
26
27
+ def test_doesnt_rewrite_dotcom_subdomain_image_urls
28
+ orig = %(<p><img src="https://raw.github.com/img.png"></p>)
29
+ assert_equal "<p><img src=\" https://raw.github.com/img.png\" ></p>" ,
30
+ CamoFilter . call ( orig , @options ) . to_s
31
+ end
32
+
33
+ def test_doesnt_rewrite_dotcom_app_image_urls
34
+ orig = %(<p><img src="https://githubapp.com/img.png"></p>)
35
+ assert_equal "<p><img src=\" https://githubapp.com/img.png\" ></p>" ,
36
+ CamoFilter . call ( orig , @options ) . to_s
37
+ end
38
+
27
39
def test_camouflaging_https_image_urls
28
40
orig = %(<p><img src="https://foo.com/img.png"></p>)
29
41
assert_includes 'img src="' + @asset_proxy_url ,
You can’t perform that action at this time.
0 commit comments