Revert "Reduce more Array object creations"

This reverts commit cac0e0431375073f4bebc5df8598bf79e863c086.

Reason: web-console gem expects the existence of `filter_proxy` and overrides this method
https://github.com/rails/web-console/blob/v4.2.0/lib/web_console/request.rb#L31-L36
This commit is contained in:
Akira Matsuda 2022-12-17 18:57:14 +09:00
parent 4fbc4bbe43
commit 01001028df
No known key found for this signature in database

@ -159,7 +159,7 @@ def calculate_ip
# If every single IP option is in the trusted list, return the IP
# that's furthest away
ips.detect {|ip| @proxies.none? {|p| p === ip } } || (@proxies.none? {|p| p === remote_addr} && remote_addr) || ips.last || remote_addr
filter_proxies(ips + [remote_addr]).first || ips.last || remote_addr
end
# Memoizes the value returned by #calculate_ip and returns it for
@ -183,6 +183,12 @@ def ips_from(header) # :doc:
end
ips
end
def filter_proxies(ips) # :doc:
ips.reject do |ip|
@proxies.any? { |proxy| proxy === ip }
end
end
end
end
end