jo3-l / obscenity

Robust, extensible profanity filter for NodeJS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: Censoring of the n-word results in more asterisks than expected

HatScripts opened this issue · comments

Expected behavior

Actual behavior

matcher.getAllMatches('nigger') results in an array of length 2, when it should only be 1. This causes the resulting censored string to be n*********r, when it should be n****r.

Screenshot 2024-01-05 171832

Minimal reproducible example

import {
  RegExpMatcher,
  TextCensor,
  englishDataset,
  englishRecommendedTransformers,
  keepStartCensorStrategy,
  keepEndCensorStrategy,
  asteriskCensorStrategy
} from 'obscenity'

const matcher = new RegExpMatcher({
  ...englishDataset.build(),
  ...englishRecommendedTransformers
})

const strategy = keepStartCensorStrategy(keepEndCensorStrategy(asteriskCensorStrategy()))
const censor = new TextCensor().setStrategy(strategy)

const input = 'nigger'

const matches = matcher.getAllMatches(input)
console.log(matches)
console.log(censor.applyTo(input, matches))

Steps to reproduce

  1. Run above code
  2. View console

Additional context

No response

Node.js version

N/A

Obscenity version

v0.1.4

Priority

  • Low
  • Medium
  • High

Terms

  • I agree to follow the project's Code of Conduct.
  • I have searched existing issues for similar reports.

This should be fixed in the newest release of Obscenity; please let me know if it persists for you.

It's working as expected now. Thank you!