Obscene words filter for nanoid
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
locale
test
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
format.js
generate.js
hasProfanity.js
index.js
non-secure.js
package-lock.json
package.json
wrapper.js

README.md

nanoid-good

Guarantees you will not get any obscene words or other profanity in your ids generated by Nano ID.

This is a drop-in replacement for Nano ID which means you can just change the name of imported package from nanoid to nanoid-good.

Installation

npm install nanoid-good

Usage

var en = require("nanoid-good/locale/en"); // you should add locale of your preferred language
var nanoid = require("nanoid-good")(en);
var id = nanoid(); //=> "V1StGXR8_Z5jdHi6B~myT"

You can also use several locales:

var en = require("nanoid-good/locale/en");
var ru = require("nanoid-good/locale/ru");
var nanoid = require("nanoid-good")(en, ru);

All additional functions of Nano ID are supported too:

var en = require("nanoid-good/locale/en");
var format = require("nanoid-good/format")(en);
var generate = require("nanoid-good/generate")(en);
var nonSecure = require("nanoid-good/non-secure")(en);

var id1 = format(random, "abcdef", 5);
var id2 = generate("1234567abcdef", 10);
var id3 = nonSecure();

How it works

It checks every generated ID through a vocabulary of obscene words. If any match is found, then ID is generated again and again until it gets clean ID which is returned.

It finds bad words with mixed registry and words which are hidden in between other letters.

For example:

Uakgb_J5m9g~0JDMpoRnqLJ

This one will be considered a bad word because of poRn hidden near the end.