1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Moved Domain regexp to a constant and added comments.

This commit is contained in:
Rizwan Reza 2010-06-11 12:12:53 +04:30 committed by José Valim
parent edbb78d6cc
commit 5609149d84

View file

@ -93,6 +93,13 @@ module ActionDispatch
:cookie_only => true
}
# This regular expression is used to split the levels of a domain:
# So www.example.co.uk gives:
# $1 => www.
# $2 => example
# $3 => co.uk
DOMAIN_REGEXP = /^(.*\.)*(.*)\.(...|...\...|....|..\...|..)$/
def initialize(app, options = {})
@app = app
@default_options = DEFAULT_OPTIONS.merge(options)
@ -123,7 +130,7 @@ module ActionDispatch
end
if options[:domain] == :all
env["HTTP_HOST"] =~ /^(.*\.)*(.*)\.(...|...\...|....|..\...)$/
env["HTTP_HOST"] =~ DOMAIN_REGEXP
options[:domain] = ".#{$2}.#{$3}"
end