Skip to content

Commit bc65d1e

Browse files
committed
Simplify and fix formatting
1 parent d1e7396 commit bc65d1e

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

‎py/selenium/webdriver/common/api_request_context.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def _cookie_matches(cookie: dict, url: str, default_domain: str = "") -> bool:
131131
return False
132132
else:
133133
# Strip optional leading dot per RFC 6265 section 5.1.3
134-
norm_domain = cookie_domain[1:] if cookie_domain.startswith(".") else cookie_domain
134+
norm_domain = cookie_domain.removeprefix(".")
135135
if not (hostname == norm_domain or hostname.endswith("." + norm_domain)):
136136
return False
137137

‎py/test/unit/selenium/webdriver/common/api_request_context_tests.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,6 @@ def test_missing_path_defaults_root():
294294
assert _cookie_matches({"name": "a", "value": "1", "domain": "example.com"}, "http://example.com/anything")
295295

296296

297-
298-
299297
def test_domain_without_leading_dot_matches_subdomain():
300298
assert _cookie_matches({"name": "a", "value": "1", "domain": "example.com"}, "http://sub.example.com/")
301299

@@ -310,6 +308,7 @@ def test_path_with_trailing_slash_matches_subpath():
310308
{"name": "a", "value": "1", "domain": "example.com", "path": "/docs/"}, "http://example.com/docs/page"
311309
)
312310

311+
313312
# --- Secure ---
314313

315314

0 commit comments

Comments
 (0)