profanity-util
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -79,3 +79,3 @@ /* | ||
var matches = [], | ||
fields = options.fields || null, | ||
fields = options.fields || Object.keys(target), | ||
result; | ||
@@ -88,11 +88,25 @@ | ||
} else if (typeof target === 'object') { | ||
util.eachRecursive(target, function (val, key, root) { | ||
if (fields && fields.indexOf(key) === -1) { | ||
return; | ||
} | ||
fields.forEach(function (field) { | ||
if (typeof val === 'string') { | ||
result = purifyString(val, options); | ||
root[key] = result[0]; | ||
// TODO: Use better recursive checking, make DRYer | ||
if (typeof target[field] === 'string') { | ||
result = purifyString(target[field], options); | ||
target[field] = result[0]; | ||
matches = matches.concat(result[1]); | ||
} else if (typeof target[field] === 'object') { | ||
util.eachRecursive(target[field], function (val, key, root) { | ||
if (fields && fields.indexOf(key) === -1) { | ||
return; | ||
} | ||
if (typeof val === 'string') { | ||
result = purifyString(val, options); | ||
root[key] = result[0]; | ||
matches = matches.concat(result[1]); | ||
} | ||
}); | ||
} | ||
@@ -108,2 +122,2 @@ }); | ||
purify: purify | ||
}; | ||
}; |
{ | ||
"name": "profanity-util", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Utility for detection, filtering and replacement / obscuration of forbidden words", | ||
@@ -5,0 +5,0 @@ "main": "lib/profanity.js", |
15707
570