mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Moved Domain regexp to a constant and added comments.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user