Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.3k
URL.port becomes Optional[int]#1080
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -273,12 +273,20 @@ def enforce_http_url(url: "URL") -> None: | ||
| raise InvalidURL('URL scheme must be "http" or "https".') | ||
| def port_or_default(url: "URL") -> typing.Optional[int]: | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this should be used above? | ||
| if url.port is not None: | ||
| return url.port | ||
| return {"http": 80, "https": 443}.get(url.scheme) | ||
| def same_origin(url: "URL", other: "URL") -> bool: | ||
| """ | ||
| Return 'True' if the given URLs share the same origin. | ||
| """ | ||
| return ( | ||
| url.scheme == other.scheme and url.host == other.host and url.port == other.port | ||
| url.scheme == other.scheme | ||
| and url.host == other.host | ||
| and port_or_default(url) == port_or_default(other) | ||
| ) | ||
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.
Should this be a
.get()to avoidKeyError: 'ftp'?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.
Actually no, because we've called
enforce_http_url(url)before doing anything else, sourl.schemewill always behttp|httpshere, anddefault_portwill be anintrather than anOptional[int].(Agree that it's a bit futzy, and I think it'd potentially clean up a bit if we rethought the proxy_keys/mount API.)