Skip to content

Commit

Permalink
gh-100519: simplification to eff_request_host in cookiejar.py (#99588)
Browse files Browse the repository at this point in the history
`IPV4_RE` includes a `.`, and the `.find(".") == -1` included here is already testing to make sure there's no dot, so this part of the expression is tautological. Instead use more modern `in` syntax to make it clear what the check is doing here. The simplified implementation more clearly matches the wording in RFC 2965.

Co-authored-by: hauntsaninja <hauntsaninja@gmail.com>
  • Loading branch information
glyph and hauntsaninja authored Dec 25, 2022
1 parent 046cbc2 commit b9aa14a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Lib/http/cookiejar.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ def eff_request_host(request):
"""
erhn = req_host = request_host(request)
if req_host.find(".") == -1 and not IPV4_RE.search(req_host):
if "." not in req_host:
erhn = req_host + ".local"
return req_host, erhn

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Small simplification of :func:`http.cookiejar.eff_request_host` that
improves readability and better matches the RFC wording.

0 comments on commit b9aa14a

Please sign in to comment.