nuxeh / url-bot-rs

Minimal IRC URL bot in Rust
ISC License
25 stars 11 forks source link

Blacklist #402

Open dabukalam opened 3 years ago

dabukalam commented 3 years ago

It would be good to be able to specify a list of URLs that one doesn't want url-bot to resolve.

nuxeh commented 3 years ago

Sure, seems like a good feature... PRs welcome ;)

How I'd go about this would be something like:

However this would then have to be an exhaustive list of URLs you want to black list, providing a domain probably wouldn't black list all urls under this domain, for example. That would require some more thought.

nuxeh commented 3 years ago

I guess one simple solution could be to have separate e.g. blacklisted_urls and blacklisted_domains configuration fields.

Then in the resolve function you could check whether blacklisted_domains contains url.domain() and bail if so.

nuxeh commented 3 years ago

Originally I thought maybe Url might itself have a contains() method, so you could identify whether the current url's path contains the blacklisted URL, but a quick look suggests not.