@@ -335,7 +335,6 @@ def basic_check(endpoint):
335
335
base_immediate = parent_domain_for (subdomain_immediate )
336
336
337
337
endpoint .redirect_immediately_to = immediate
338
- endpoint .redirect_immediately_to_www = (re .match (r'^https?://www\.' , immediate ) is not None )
339
338
endpoint .redirect_immediately_to_https = immediate .startswith ("https://" )
340
339
endpoint .redirect_immediately_to_http = immediate .startswith ("http://" )
341
340
endpoint .redirect_immediately_to_external = (base_original != base_immediate )
@@ -344,6 +343,14 @@ def basic_check(endpoint):
344
343
(subdomain_original != subdomain_immediate )
345
344
)
346
345
346
+ # We're interested in whether an endpoint redirects to the www version
347
+ # of itself (not whether it redirects to www prepended to any other
348
+ # hostname, even within the same parent domain).
349
+ endpoint .redirect_immediately_to_www = (
350
+ subdomain_immediate .startswith ("www." ) and
351
+ (re .sub ("www\." , "" , subdomain_immediate ) == subdomain_original )
352
+ )
353
+
347
354
if ultimate_req is not None :
348
355
# For ultimate destination, use the URL we arrived at,
349
356
# not Location header. Auto-resolves relative redirects.
@@ -592,12 +599,6 @@ def root_down(endpoint):
592
599
)
593
600
)
594
601
595
- def goes_to_www (endpoint ):
596
- return (
597
- endpoint .redirect_immediately_to_www and
598
- (not endpoint .redirect_immediately_to_external )
599
- )
600
-
601
602
all_roots_unused = root_unused (https ) and root_unused (http )
602
603
603
604
all_roots_down = root_down (https ) and root_down (http )
@@ -606,8 +607,8 @@ def goes_to_www(endpoint):
606
607
at_least_one_www_used and
607
608
all_roots_unused and (
608
609
all_roots_down or
609
- goes_to_www ( https ) or
610
- goes_to_www ( http )
610
+ https . redirect_immediately_to_www or
611
+ http . redirect_immediately_to_www
611
612
)
612
613
)
613
614
0 commit comments