File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
lib/action_dispatch/middleware Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -461,8 +461,8 @@ def handle_options(options)
461461 # Case where tld_length is not provided
462462 else
463463 # Regular TLDs
464- if !( /( [^.]{2,3}\. [^.]{2})$ / . match? ( request . host ) )
465- cookie_domain = dot_splitted_host . last ( 2 ) . join ( '.' )
464+ if !( /\. [^.]{2,3}\. [^.]{2}\z / . match? ( request . host ) )
465+ cookie_domain = dot_splitted_host . last ( 2 ) . join ( "." )
466466 # **.**, ***.** style TLDs like co.uk and com.au
467467 else
468468 cookie_domain = dot_splitted_host . last ( 3 ) . join ( '.' )
Original file line number Diff line number Diff line change @@ -1070,6 +1070,20 @@ def test_cookie_with_all_domain_option_using_uk_style_tld
10701070 assert_cookie_header "user_name=rizwanreza; domain=.nextangle.co.uk; path=/; SameSite=Lax"
10711071 end
10721072
1073+ def test_cookie_with_all_domain_option_using_two_letter_one_level_tld
1074+ @request . host = "hawth.ca"
1075+ get :set_cookie_with_domain
1076+ assert_response :success
1077+ assert_cookie_header "user_name=rizwanreza; domain=.hawth.ca; path=/; SameSite=Lax"
1078+ end
1079+
1080+ def test_cookie_with_all_domain_option_using_two_letter_one_level_tld_and_subdomain
1081+ @request . host = "x.hawth.ca"
1082+ get :set_cookie_with_domain
1083+ assert_response :success
1084+ assert_cookie_header "user_name=rizwanreza; domain=.hawth.ca; path=/; SameSite=Lax"
1085+ end
1086+
10731087 def test_cookie_with_all_domain_option_using_uk_style_tld_and_two_subdomains
10741088 @request . host = "x.nextangle.co.uk"
10751089 get :set_cookie_with_domain
You can’t perform that action at this time.
0 commit comments