File tree 2 files changed +16
-2
lines changed
lib/action_dispatch/middleware
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)
461
461
# Case where tld_length is not provided
462
462
else
463
463
# 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 ( "." )
466
466
# **.**, ***.** style TLDs like co.uk and com.au
467
467
else
468
468
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
1070
1070
assert_cookie_header "user_name=rizwanreza; domain=.nextangle.co.uk; path=/; SameSite=Lax"
1071
1071
end
1072
1072
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
+
1073
1087
def test_cookie_with_all_domain_option_using_uk_style_tld_and_two_subdomains
1074
1088
@request . host = "x.nextangle.co.uk"
1075
1089
get :set_cookie_with_domain
You can’t perform that action at this time.
0 commit comments