Skip to content

xxRockOnxx/stevenblack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stevenblack

This is a tiny package that checks if a domain is blacklisted in StevenBlack hosts file

This package will always pull the latest hosts file from the main repo https://github.com/StevenBlack/hosts during installation.

I created this package for my needs which is to block NSFW links from my projects.

Installation

npm install stevenblack

Usage

The default export of this package is a function that returns a Promise with a boolean value.

It reads the downloaded hosts file line by line and compare it against the given string.

It throws an error if for some reason the hosts file does not exists.

const isBlacklisted = require('stevenblack')

async function main() {
  if (await isBlacklisted('nsfw-domain.com')) {
    throw new Error('Domain is blacklisted')
  }

  console.log('All good!')
}

main()

About

A package that checks if a domain is blacklisted in StevenBlack hosts file

Resources

Stars

Watchers

Forks

Packages

No packages published