Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
bad-words-next
Advanced tools
JavaScript/TypeScript filter and checker for bad words aka profanity.
API documentation in GitHub Wiki.
yarn add bad-words-next
or
npm install bad-words-next
const BadWordsNext = require('bad-words-next')
const en = require('bad-words-next/data/en.json')
const badwords = new BadWordsNext({ data: en })
// Returns true when passed string contains a bad word
console.log(badwords.check('S0me sh!tt is here'))
// will print `true`
// Returns filtered string with masked bad words
console.log(badwords.filter('S0me sh!tt is here'))
// will print `S0me *** is here`
const BadWordsNext = require('bad-words-next')
const en = require('bad-words-next/data/en.json')
const es = require('bad-words-next/data/es.json')
const fr = require('bad-words-next/data/fr.json')
const de = require('bad-words-next/data/de.json')
const ru = require('bad-words-next/data/ru.json')
const rl = require('bad-words-next/data/ru_lat.json')
const ua = require('bad-words-next/data/ua.json')
const pl = require('bad-words-next/data/pl.json')
const ch = require('bad-words-next/data/ch.json')
const badwords = new BadWordsNext()
badwords.add(en)
badwords.add(es)
badwords.add(fr)
badwords.add(de)
badwords.add(ru)
badwords.add(rl)
badwords.add(ua)
badwords.add(pl)
badwords.add(ch)
interface Data {
id: string // Unique dictionary ID
words: string[] // Words list
lookalike: Lookalike // Lookalike homoglyphs map
}
interface Lookalike {
[key: string | number]: string // Simple key-value object
}
You can use the following pattern characters in a word string:
*
indicates any characters, use it only on start and/or end of a word+
indicates one or more repeating characters_
indicates special charactersinterface Options {
data?: Data // Dictionary data
placeholder?: string // Filter placeholder - default '***'
specialChars?: RegExp // Special chars to allow on start and/or end of a word - default /\d|[!@#$%^&*()[\];:'",.?\-_=+~`|]|a|(?:the)|(?:el)|(?:la)/
spaceChars?: string[] // Pseudo space chars, a list of values for `_` symbol in a dictionary word string - default ['', '.', '-', ';', '|']
confusables?: string[] // List of ids to apply transformations from `confusables` npm package - default ['en', 'es', 'de', 'ru_lat']
maxCacheSize?: number // Max items to store in cache - default 100
}
See Options API for more details.
Dictionary words with spaces won't work b/c they do not represent a single word
Dictionaries have to be improved over time
FAQs
JavaScript/TypeScript filter and checker for bad words aka profanity
The npm package bad-words-next receives a total of 1,329 weekly downloads. As such, bad-words-next popularity was classified as popular.
We found that bad-words-next demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.