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

Support loading external data file #16

Open
gavincarr opened this issue Nov 28, 2017 · 2 comments
Open

Support loading external data file #16

gavincarr opened this issue Nov 28, 2017 · 2 comments
Assignees

Comments

@gavincarr
Copy link

gavincarr commented Nov 28, 2017

Hey @lupomontero,

I'm enjoying using psl - thanks for your work on it!

One extra I'd like is the ability to load the rules from an external data file rather than using the internal one. This might just be to track the upstream MPSL more closely, or it would allow you to fork the MPSL and make custom changes for particular applications. Would you be open to this kind of change?

If so, what kind of interface would you like? I've got a prototype in my fork:

https://github.com/gavincarr/psl

that allows you to do e.g. var psl = require('psl').loadData('effective_tld_names.dat'); to synchronously load a (MPSL format, not json) data file at require time.

Thoughts?

@lupomontero lupomontero self-assigned this Dec 4, 2017
@lupomontero
Copy link
Owner

Hi @gavincarr,

Thanks for the suggestion 👍

At the moment this library works both on the server and the browser, so adding Node's fs as a dependency can be a bit a bit tricky. It probably makes sense to keep the file system stuff outside of psl. We could maybe provide a function to set or override the rules, so that userland code could use their own custom rules without psl having to know about the where the rules came from (ie: the file system).

Alternatively, we could tweak the build process to allow you to chose what dat file to use...

Thoughts?

L

@justanotheranonymoususer

Nice library, and I have the same feature request. I actually use it in a browser environment, so I don't have fs. My goal is to download a fresh version of the list and cache it in local storage, and re-download it once it expires (say, a month).

Perhaps the library can can allow to receive the content of effective_tld_names.dat as a string, and it would be up to the user to fetch the file contents. Then it can be done via fetch in the browser.

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

No branches or pull requests

3 participants