Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,13 @@ def stale_session_check! | |
: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 = /^(.*\.)*(.*)\.(...|...\...|....|..\...|..)$/ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
rizwanreza
Author
Contributor
|
||
|
||
def initialize(app, options = {}) | ||
@app = app | ||
@default_options = DEFAULT_OPTIONS.merge(options) | ||
|
@@ -123,7 +130,7 @@ def call(env) | |
end | ||
|
||
if options[:domain] == :all | ||
env["HTTP_HOST"] =~ /^(.*\.)*(.*)\.(...|...\...|....|..\...)$/ | ||
env["HTTP_HOST"] =~ DOMAIN_REGEXP | ||
options[:domain] = ".#{$2}.#{$3}" | ||
end | ||
|
||
|
I'm wondering what it does in case the tld is longer than four characters, like, say, in
http://موقع.وزارة-الاتصالات.مصر/
which should translate to
http://xn--4gbrim.xn----ymcbaaajlc6dj7bxne2c.xn--wgbh1c/