Skip to content

Commit

Permalink
fix: minor fixes for name redaction
Browse files Browse the repository at this point in the history
  • Loading branch information
justbbetter committed Dec 21, 2017
1 parent 46d26f0 commit f6914ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var newlineRegex = /([\n\f\r-]+\s*)/gi;
module.exports = {
greetOrClose: new RegExp(`(((${greetingRegex.source})|(${closingRegex.source}\\s*[,.!]*))[\\s-]*)`, 'gi'),
nameGeneric: new RegExp(`( ?(([A-Z][a-z]+)|([A-Z]\\.)))+([,.]|[,.]?$)`, 'gm'),
names: new RegExp(`${newlineRegex.source}( ?(${names.join('|')}))+`, 'gi'),
names: new RegExp(`${newlineRegex.source}([. ]*(${names.join('|')}))+ *$`, 'gim'),
creditCardNumber: /\d{4}[ -]?\d{4}[ -]?\d{4}[ -]?\d{4}|\d{4}[ -]?\d{6}[ -]?\d{4}\d?/g,
streetAddress: new RegExp(`(\\d+\\s*(\\w+ ){1,2}${roadRegex.source}(\\s+${aptRegex.source})?)|(${poBoxRegex.source})`, 'gi'),
zipcode: /\b\d{5}\b(-\d{4})?\b/g,
Expand Down
5 changes: 3 additions & 2 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ defineTest('index.js', function (Redactor) {
});

it('should replace names', function () {
redactor.redact('blah blah\n\nThank you ..Risemamy McCrubben').should.equal('blah blah\n\nThank you ..NAME');;
redactor.redact('blah blah. Thanks -Jon').should.equal('blah blah. Thanks -NAME');;
redactor.redact('blah blah\nThis is very important.').should.equal('blah blah\nThis is very important.');
redactor.redact('blah blah\n\nThank you ..Risemamy McCrubben').should.equal('blah blah\n\nThank you ..NAME');
redactor.redact('blah blah. Thanks -Jon').should.equal('blah blah. Thanks -NAME');
redactor.redact('here\'s my Cliff. blah blah').should.equal('here\'s my Cliff. blah blah');
redactor.redact('here\'s my Clifford. blah blah').should.equal('here\'s my Clifford. blah blah');
redactor.redact('Dear Clifford,\n blah blah').should.equal('Dear NAME,\n blah blah');
Expand Down

0 comments on commit f6914ff

Please sign in to comment.