censor_it 2.2.0
censor_it: ^2.2.0 copied to clipboard
A Dart library for censoring text based on predefined patterns and customizable characters.
2.2.0 #
Added #
String.censor()extension - ReplacesString.censored()(random character replacement). The new name no longer looks like thecensoredgetter ofCensorIt, which does a different job
Deprecated #
String.censored()extension - UseString.censor()instead
Fixed #
- False positives in
LanguagePattern.all- Ordinary words such ascustomer,cute,cup,horizon,vitamin,pistol,Pisaand Russianсебя/себеare no longer detected as profanity:- Portuguese:
cumatches onlycu,cuzãoandcuzona, not everycu* - Finnish:
vitt?u*instead ofvit* - Swedish: explicit
hora/horor/horungeforms instead ofhor* - Latvian:
pistol,piston,pistachioandPisano longer match - Russian: the bare prefix
сno longer combines with theебroot (съебатьis still detected) - Italian:
cazzuola,stronzio; French:salopette
- Portuguese:
CensorPattern.multi([])- An empty list now matches nothing. Previously the combined regular expression matched an empty string at every position, so any text was reported as profane- Documentation examples -
CensorIt.randomexample inREADME_RU.md(r'\$'is two characters and threwArgumentError), output of the string extension, number of supported languages, snippets inMIGRATION.md
Changed #
- Performance - Language regular expressions are compiled once instead of on
every access. The combined regular expression of
CensorPattern.multiis built once per instance,LanguagePattern.fromLocalesmemoizes the combined pattern, andmatchesis computed once perCensorItinstance (hasProfanityandswearWordsreuse it) GetMatchesX.matchesreturns an unmodifiable listCensorPattern.multitreatspatternsas immutable - The list must not be modified after the first use ofregExp
2.1.2 #
- Add pavluke_lints
2.1.1 #
- Downgrade min requirement Dart SDK to 3.6.0
- Replace ccTLD codes with ISO 639-1 language codes
2.1.0 #
2.0.0 #
Breaking Changes #
- Main constructor replaced with factory constructors - Use
CensorIt.random(),CensorIt.mask(),CensorIt.builder(), orCensorIt.replace() CensorPatternrenamed toLanguagePattern- Better semantic naming- Changed from
enumtosealed class- Better type safety and extensibility - Removed
regenerateCensoredText()- Useregenerate()instead (only forCensorIt.random()) - Removed
toCensorIt()extension - Use factory constructors directly fromPatterns()renamed tomulti()-CensorPattern.multi([...])- SDK minimum version raised to
^3.10.0
Added #
CensorIt.random()factory - Random character replacement (replaces old constructor)CensorIt.mask()factory - Simple character masking (e.g.,****)CensorIt.builder()factory - Custom replacement logic with builder functionCensorIt.replace()factory - Fixed string replacement (e.g.,[censored])- Locale-based pattern selection -
LanguagePattern.fromLocale('lv') - Multi-locale patterns -
LanguagePattern.fromLocales(['en', 'ru', 'es']) - Simplified
.censored()extension - Direct string censoring CensorIt.defaultCharsconstant - Reference default censoring characters- Better validation - Validates single-character elements and non-empty lists
Fixed #
- Case preservation bug - Censored text now correctly maintains original case
- Custom pattern independence - Each custom pattern has its own RegExp instance
- Factory constructor bug - Multiple calls no longer interfere with each other
- Infinite loop protection - Added fallback mechanism for edge cases
Changed #
- Constructor replaced with factory methods for different strategies
- Pattern class renamed:
CensorPattern→LanguagePattern - Combining patterns:
fromPatterns()→CensorPattern.multi() - File structure reorganized into
core/,patterns/,extensions/
Removed #
toCensorIt()extension method- Default
CensorIt()constructor regenerateCensoredText()method
Migration Guide #
See MIGRATION.md for detailed step-by-step instructions.
1.2.4 #
- Set type annotation on CensorPattern static methods
- Update README.md
- Update example
- Update pubspec.yaml
1.2.3 #
- Update README.md
1.2.2 #
- Update README.md
1.2.1 #
- Update README.md
- Update LICENSE
- Update example
1.2.0 #
- Refactored regexps
- Added regexps tests
- Deprecated stream
1.1.1 #
- Update README.md
1.1.0 #
- Added extension [CensorIt] on [String]
1.0.4 #
- Enum changes
1.0.3 #
- Removed bang operator
1.0.2 #
- Updated docs.
1.0.1 #
- Updated docs.
1.0.0 #
- Initial version.
