Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.17.0
22.19.0
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,21 @@ profanity.censor('I like big butts and I cannot lie', CensorType.AllVowels);
// I like big b$tts and I cannot lie
```

### unicodeWordBoundaries

Controls whether word boundaries are Unicode-aware. By default this is set to `false` due to the performance impact.

- When `false` (default), whole-word matching uses ASCII-style boundaries (similar to `\b`) plus underscore `_` as a separator. This is fastest and ideal for ASCII inputs.
- When `true`, whole-word matching uses Unicode-aware boundaries so words with diacritics (e.g., `vehículo`, `horário`) and compound separators are handled correctly.

```JavaScript
// Enable Unicode-aware boundaries when processing non-ASCII input
const profanity = new Profanity({ unicodeWordBoundaries: true });

profanity.exists('vehículo horario');
// false (does not match on "culo" inside "vehículo")
```

## Customize the word list

Add words:
Expand Down
4 changes: 0 additions & 4 deletions contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ The Profanity project includes an .nvmrc file, so you can run `nvm use` to switc

The Profanity project includes Husky for running Git Hooks. Running `git commit` will trigger `lint-staged` which will lint all files currently staged in Git. If linting fails, the commit will be cancelled

### Dependencies

- `chai`: we must use v4.x because v5.x is pure ESM, and we require CommonJS modules

### Translations

We utilize a self-hosted instance of the Open Source [LibreTranslate](https://github.com/LibreTranslate/LibreTranslate) lib to translate the core English list of profane words.
Expand Down
9 changes: 9 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ export default [
js.configs.recommended,
...ts.configs.recommended,
security.configs.recommended,
{
// Disable noisy security warnings that are intentional in this codebase
rules: {
// Dynamic regex construction is required for the profanity alternation
"security/detect-non-literal-regexp": "off",
// Indexed access in benchmarks/translate is safe in our context
"security/detect-object-injection": "off",
},
},
{
// These file-matching rules will be processed after the above configs
files: ["**/*.{js,ts}"],
Expand Down
Loading