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](https://private-user-images.githubusercontent.com/5691865/294409222-986dbbf1-4332-4440-9a0e-60b9e6814bcc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMzI0MjYsIm5iZiI6MTcyNTIzMjEyNiwicGF0aCI6Ii81NjkxODY1LzI5NDQwOTIyMi05ODZkYmJmMS00MzMyLTQ0NDAtOWEwZS02MGI5ZTY4MTRiY2MucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDkwMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA5MDFUMjMwODQ2WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MGMxZjJhNmU2Yjg0ZmE1MzljNjkzYTkwMWRlZTM0MTYzYmUzMmY3OTc1YjRhOTgwNDdkM2I5ZDNiODliZGUzMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.s_E1sIOhptP3Rvsc_ubtqX0VMMA_fO2ewv-WxOjAWaI)
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
- Run above code
- 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!