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:
parent
edbb78d6cc
commit
5609149d84
1 changed files with 8 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue