Skip to content

Commit

Permalink
Accept both regexps and strings for LOCALHOST.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jun 8, 2010
1 parent 068f8d6 commit 68b4720
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions actionpack/lib/action_dispatch/middleware/show_exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module ActionDispatch
# This middleware rescues any exception returned by the application and renders
# nice exception pages if it's being rescued locally.
class ShowExceptions
LOCALHOST = [/^127\.0\.0\.\d{1,3}$/, /^::1$/, /^0:0:0:0:0:0:0:1(%.*)?$/].freeze
LOCALHOST = [/^127\.0\.0\.\d{1,3}$/, "::1", /^0:0:0:0:0:0:0:1(%.*)?$/].freeze

RESCUES_TEMPLATE_PATH = File.join(File.dirname(__FILE__), 'templates')

Expand Down Expand Up @@ -114,7 +114,7 @@ def rescue_action_in_public(exception)

# True if the request came from localhost, 127.0.0.1.
def local_request?(request)
LOCALHOST.any?{ |local_ip| request.remote_addr =~ local_ip && request.remote_ip =~ local_ip }
LOCALHOST.any? { |local_ip| local_ip === request.remote_addr && local_ip === request.remote_ip }
end

def status_code(exception)
Expand Down

0 comments on commit 68b4720

Please sign in to comment.