New Features
- Added email address protection - valid email addresses are now preserved during sanitization
- Introduced
removeMatches
option to completely remove matched patterns instead of replacing them
- Changed default values for
allowedKeys
and deniedKeys
from null
to []
Improvements
- Optimized
sanitizeValue
function with early returns for better performance
- Enhanced object sanitization with more thorough pattern matching
- Added request object cloning in
handleRequest
for safer sanitization
- Fixed string length truncation to only apply to values, not keys
Bug Fixes
- Fixed string length truncation only applying to values
- Improved handling of email addresses in nested objects
- Enhanced pattern matching safety
Usage Example
const fastify = require('fastify')();
const mongoSanitize = require('@exortek/fastify-mongo-sanitize');
fastify.register(mongoSanitize, {
removeMatches: true, // New option to remove matched patterns
stringOptions: {
maxLength: 100,
trim: true
}
});