aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-02-28 17:43:03 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-02-28 17:48:26 -0800
commit8cecb476966b7ec61a31fd08e96afb67931eac3d (patch)
treef1653e5c408f894e87c0068686b375e4d5a10a64
parentc512730cf28446112489b82be4bae1a622ede0d3 (diff)
downloadrails-8cecb476966b7ec61a31fd08e96afb67931eac3d.tar.gz
rails-8cecb476966b7ec61a31fd08e96afb67931eac3d.tar.bz2
rails-8cecb476966b7ec61a31fd08e96afb67931eac3d.zip
reduced localhost check to two method calls
-rw-r--r--actionpack/lib/action_dispatch/http/request.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb
index de014a9c00..796e0dbc45 100644
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -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