Skip to content

Commit

Permalink
Use more compatible URI#host
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Jan 13, 2014
1 parent e0cf905 commit 8b00aac
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/html/pipeline/camo_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 8b00aac

Please sign in to comment.