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 20, 2017
1 parent 5156a5f commit 46d26f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var closingRegex = /(thx|thanks|thank you|regards|best|[a-z]+ly|[a-z]+ regards|a
var newlineRegex = /([\n\f\r-]+\s*)/gi;

module.exports = {
greetOrClose: new RegExp(`(((${greetingRegex.source})|(${closingRegex.source}[,.!]?))[\\s-]+)`, 'gi'),
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'),
creditCardNumber: /\d{4}[ -]?\d{4}[ -]?\d{4}[ -]?\d{4}|\d{4}[ -]?\d{6}[ -]?\d{4}\d?/g,
Expand Down
2 changes: 2 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ 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('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 46d26f0

Please sign in to comment.