Skip to content
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

Extract port #273

Closed
wants to merge 2 commits into from
Closed

Extract port #273

wants to merge 2 commits into from

Conversation

john-kurkowski
Copy link
Owner

@john-kurkowski john-kurkowski commented Sep 20, 2022

  • Add optional port as the 4th member of the ExtractResult namedtuple
  • Deemphasize documentation about rejoining the ExtractResult namedtuple members by dot
    • Since port in a URL-like string is optional and joined by colon, not dot

Fixes #272.

Compatibility

  • This breaks the previously documented ".".join(extract_result) pattern
    • If callers aren't careful, the pattern will produce awkward strings like "foo.bar.com.None" or "foo.bar.com.8080", or raise a TypeError from trying to join str with Optional[int]
    • Arguably, relying on an ExtractResult being a namedtuple is historical. Still, this PR would complicate things for users relying on that join.

Other Options

  1. Make port an attribute of ExtractResult but not a member of the tuple, like urllib.parse.urlsplit does
  2. Don't merge this; callers can get the port using the standard library (and the port is validated)

@john-kurkowski
Copy link
Owner Author

After thinking about it, this library is focused on domain names, not every component of a URL. I defer URL parsing to Python's standard lib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get the port from the provided URL to extract function
1 participant