From 8b00aacad41340b008b4c874b00c5f9a80ab5a5e Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 13 Jan 2014 16:10:21 -0600 Subject: [PATCH] Use more compatible URI#host --- lib/html/pipeline/camo_filter.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/html/pipeline/camo_filter.rb b/lib/html/pipeline/camo_filter.rb index e2334d5a..e68471b9 100644 --- a/lib/html/pipeline/camo_filter.rb +++ b/lib/html/pipeline/camo_filter.rb @@ -14,7 +14,7 @@ class Pipeline # Context options: # :asset_proxy (required) - Base URL for constructed asset proxy URLs. # :asset_proxy_secret_key (required) - The shared secret used to encode URLs. - # :asset_proxy_whitelist - Array of hostname Strings or Regexps to skip + # :asset_proxy_whitelist - Array of host Strings or Regexps to skip # src rewriting. # # This filter does not write additional information to the context. @@ -33,8 +33,8 @@ def call next end - next if uri.hostname.nil? - next if asset_hostname_whitelisted?(uri.hostname) + next if uri.host.nil? + next if asset_host_whitelisted?(uri.host) element['src'] = asset_proxy_url(uri.to_s) element['data-canonical-src'] = uri.to_s @@ -64,7 +64,7 @@ def asset_proxy_enabled? !context[:disable_asset_proxy] end - # Private: the hostname to use for generated asset proxied URLs. + # Private: the host to use for generated asset proxied URLs. def asset_proxy_host context[:asset_proxy] end @@ -77,9 +77,9 @@ def asset_proxy_whitelist context[:asset_proxy_whitelist] || [] end - def asset_hostname_whitelisted?(hostname) + def asset_host_whitelisted?(host) asset_proxy_whitelist.any? do |test| - test.is_a?(String) ? hostname == test : test.match(hostname) + test.is_a?(String) ? host == test : test.match(host) end end