-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
proposal: ipv4 property #128
Comments
Seems good so far! There's already an IPv4 regex in the source. There should be plenty in the wild. It could shorten that example implementation. Could you provide some code examples of tasks this makes easier? That's awkward to do without the new property? |
One common use case is to ask "Hey, is this URL-looking thing (probably) a valid URL?" There are a lot of ways to potentially write that as code, but it often largely boils down to something like...
the idea is to just consolidate it a bit:
it's not too hard to do the ipv4 stuff in othercode, but doing it in tldextract keeps others from reimplementing things and avoids another parsing of a full URL (if that is the input). in other words, if |
Thank you. Got it. Before, I was thinking, what could users infer from existing properties, like @property
def is_possibly_a_valid_public_url()
return self.registered_domain or (not self.suffix and not self.subdomain and IPV4_RE.match(self.domain)) But we should only give users the tools to answer what their definition of "possibly" is. We shouldn't define it for them. |
I wanted to propose a property to support potential IPv4 addresses.
This is definitely offtopic as an IPv4 isn't a TLD - however the input to this library can often be a URL and it is often used as part of URL/HOST validation. Detecting this within the package makes it a bit easier for developers to support handling situations where a the 'domain' is invalid, however it is a valid resource.
A possible implementation is below -- in the absence of a suffix or subdomain, the domain is checked to match 4 groups of integers 0-255.
The text was updated successfully, but these errors were encountered: