diff options
author | Rizwan Reza <rizwanreza@gmail.com> | 2010-06-11 12:12:53 +0430 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-11 16:34:52 +0200 |
commit | 5609149d844ece5020dd53565d35cf69f563a8da (patch) | |
tree | 093474f36f3460969a235a946aad745e1585fa62 /actionpack | |
parent | edbb78d6cc3ec0ce4a73b765f7bb4b7c079c8a36 (diff) | |
download | rails-5609149d844ece5020dd53565d35cf69f563a8da.tar.gz rails-5609149d844ece5020dd53565d35cf69f563a8da.tar.bz2 rails-5609149d844ece5020dd53565d35cf69f563a8da.zip |
Moved Domain regexp to a constant and added comments.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/session/abstract_store.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb b/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb index 0c4ceb5c39..b03244d025 100644 --- a/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb +++ b/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb @@ -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 |