Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 of 5 tasks
HatScripts opened this issue Jan 5, 2024 · 2 comments
Closed
3 of 5 tasks
Labels
bug Something isn't working

Comments

@HatScripts
Copy link
Contributor

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.
@HatScripts HatScripts added the bug Something isn't working label Jan 5, 2024
@jo3-l jo3-l closed this as completed in e135be5 Jan 5, 2024
@jo3-l
Copy link
Owner

jo3-l commented Jan 5, 2024

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

@HatScripts
Copy link
Contributor Author

It's working as expected now. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants