weppos / publicsuffix-ruby

Domain name parser for Ruby based on the Public Suffix List.
https://simonecarletti.com/code/publicsuffix
MIT License
614 stars 110 forks source link

New release after every list update #265

Closed matias-sclavi closed 10 months ago

matias-sclavi commented 10 months ago

Hi!

We are having an error that is fixed by one of the latest public suffixes list updates. Shouldn't a release be done every time the list is updated?

Thanks!

weppos commented 10 months ago

Thanks for your suggestion @matias-sclavi . I've thought about it in the past, but with the frequency the list is updated (close to daily), we will end up with a very large number of released which in many cases is an excessive overhead.

There is also no guarantee that main is perfectly in sync with the list.

If you need to use the latest version, the library supports the ability to load an arbitrary list in the PSL format. You can have your own script to download the list as frequently as you need, and initiate the lib with a list from a local path instead of using the default list.

geeksam commented 10 months ago

@weppos Good to know. At first glance, I don't see any documentation about that feature. Poking through the code, it looks like something like this would work:

list_text = File.read('path/to/updated/list')
list = PublicSuffix::List.parse(list_text)
PublicSuffix::List.default = list

Is that correct? If so I'll send a PR to add that to the README.

Also, how would you feel about adding a top-level convenience method to turn the above snippet into a one-liner? Maybe something like PublicSuffix.load_custom_list? If you're open to that, I can send a separate "straw man" PR.

weppos commented 10 months ago

Yes, that code is correct. There is a similar example in the README for building a custom list without private names, but you are right an example with a custom list is a good idea. https://github.com/weppos/publicsuffix-ruby/blob/main/README.md#private-domains

There is also a second approach, which is building a list instance and then query against it, rather than replacing the default list. This is somewhat a preferrable approach if you deal with an environment where overriding a global variable is an undesirable effect.

For now, I'd rather not add a convenient method for it. It will require extra maintenance effort for little gain, if it is properly documented.