mirror of https://github.com/rails/rails
reduced localhost check to two method calls
This commit is contained in:
parent
c512730cf2
commit
8cecb47696
|
@ -17,7 +17,8 @@ module ActionDispatch
|
|||
include ActionDispatch::Http::Upload
|
||||
include ActionDispatch::Http::URL
|
||||
|
||||
LOCALHOST = [/^127\.0\.0\.\d{1,3}$/, "::1", /^0:0:0:0:0:0:0:1(%.*)?$/].freeze
|
||||
LOCALHOST = Regexp.union [/^127\.0\.0\.\d{1,3}$/, /^::1$/, /^0:0:0:0:0:0:0:1(%.*)?$/]
|
||||
|
||||
ENV_METHODS = %w[ AUTH_TYPE GATEWAY_INTERFACE
|
||||
PATH_TRANSLATED REMOTE_HOST
|
||||
REMOTE_IDENT REMOTE_USER REMOTE_ADDR
|
||||
|
@ -250,7 +251,7 @@ module ActionDispatch
|
|||
|
||||
# True if the request came from localhost, 127.0.0.1.
|
||||
def local?
|
||||
LOCALHOST.any? { |local_ip| local_ip === remote_addr && local_ip === remote_ip }
|
||||
LOCALHOST =~ remote_addr && LOCALHOST =~ remote_ip
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Reference in New Issue