-
-
Notifications
You must be signed in to change notification settings - Fork 806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor httpx/_utils.py
#1943
Refactor httpx/_utils.py
#1943
Conversation
self.host_regex = re.compile(f"^{domain}$") | ||
# example.com should match "example.com" but not "www.example.com" | ||
domain = re.escape(url.host) | ||
self.host_regex = re.compile(f"^{domain}$") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the refactoring you've done on this block, yup. I think it makes enough of a readability difference that it's worth having in.
httpx/_utils.py
Outdated
@@ -23,7 +23,7 @@ | |||
{chr(c): "%{:02X}".format(c) for c in range(0x1F + 1) if c != 0x1B} | |||
) | |||
_HTML5_FORM_ENCODING_RE = re.compile( | |||
r"|".join([re.escape(c) for c in _HTML5_FORM_ENCODING_REPLACEMENTS.keys()]) | |||
r"|".join([re.escape(c) for c in _HTML5_FORM_ENCODING_REPLACEMENTS]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could go either way on this one. Possibly it's more obvious with .keys()
what the effect is. Possibly not. But, okay, sure.
Okay, I've reverted one |
@tomchristie that's great, if there is any other things we can discuss about it and fix it 🚀 |
I've reverted the minor change to Given that I think those are a clear win, let's just pull those in as a single nicely scoped pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice little improvement to the flow there, thank you!
Based on what @tomchristie recommended to make #1909 this PR into a shorter one to validate multiple things and let it more clear and ready for review.