-
Notifications
You must be signed in to change notification settings - Fork 24
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
Handling suffixes not in the public list #15
Comments
The publicsuffix.org spec specifies what compliant libraries are supposed to do in this situation:
(See number 2 under "Algorithm"). We also rely on the test file they provide, which includes test cases for this case (see "Unlisted TLD" section). In order to pass those tests, we must follow the published spec. |
Ah, I see! Still, perhaps it could be an optional parameter disabled by default? The library could then be used to answer a question like "Does this look like a sane public domain name?", which can sometimes be handy. I understand if you don't want to add it, though. Thanks for the module, anyway, I used publicsuffix-erl before but it gave me headaches with exrm. Edit: Or just another function, e.g. |
Yep, same thing happened with us. That's what led to us creating this library. Anyhow, one of the issues with returning All that's to say: if a domain string does not match any rules in the list, I don't think that necessarily means it is invalid, and I wouldn't want to expose an API that claims it as such. I think we can give you what you want, with a slightly different API, though:
Basically, we can expose a function that gives you the prevailing rule. If we return On a side note, @benkirzhner have been discussing if we should switch to a single
Thoughts? |
That makes total sense and (since I've now learned a bit about the spec) it seems more reasonable and elegant than the solutions I've seen in similar libraries for other languages.
Sounds like a good idea! Fits well with how Elixir's URI module (which one might want to use at the same time) does it. |
Would you be interested in working up a PR to make the discussed changes, @andersju? |
Sure thing. I'm still fairly new to Elixir but I'll give it a go (might not have time until a week or two from now though). |
Thanks for taking this on, @andersju! I just had a chat with @myronmarston, and we think a good plan for now would be to expose two new functions:
This way, we get the flexibility of being able to see the prevailing rule (for debugging purposes, for example) while having a simpler API for the use case you originally described that doesn't require explicit knowledge of the fallback "*" case. How does that sound? |
Sounds good! I already cooked up a quick solution (but need to write tests and docs). Question though: should I think the latter would be more useful:
...but
What do you think? |
I confess I don't understand the distinction you are making. Both So I don't see how But maybe I'm missing something? |
Basically, I want to determine "does the given string contain a registrable part and, if so, does its public suffix match an explicit rule?". So I want "example", "example.notatld", "com" to evaluate to false. But I figure a So, to answer the initial question, I think we could either create an additional function or simply make it possible to pipe the output from
Make sense? |
Actually, |
Thanks for explaining. I think I understand your use case better now. I was confused previously because it sounded like you were trying to decide if
With pattern matching, it's really not bad...we just need a function clause like: def matches_explicit_rule?(nil), do: false While I don't want to support every elixir type, |
I've released 0.3.0 with your changes. |
I think it would make sense for the library to handle domains that don't have a valid public suffix (possibly as an option).
Right now (with 0.2.0):
Suggested:
Or something like that. This is how publicsuffix-erl does it, e.g.:
The text was updated successfully, but these errors were encountered: