diff --git a/lib/patterns.js b/lib/patterns.js index cd45dcc..8e653e4 100644 --- a/lib/patterns.js +++ b/lib/patterns.js @@ -12,11 +12,12 @@ module.exports = { zipcode: /\b\d{5}\b(-\d{4})?\b/gi, phoneNumber: /(\(?\+?[0-9]{1,2}\)?[-. ]?)?(\(?[0-9]{3}\)?|[0-9]{3})[-. ]?([0-9]{3}[-. ]?[0-9]{4}|\b[A-Z0-9]{7}\b)/g, ipAddress: /(\d{1,3}(\.\d{1,3}){3}|[0-9A-F]{4}(:[0-9A-F]{4}){5}(::|(:0000)+))/gi, - emailAddress: /([a-z0-9_\-.+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-z0-9-]+\.)+))([a-z]{2,4}|[0-9]{1,3})(]?)/gi, + emailAddress: /([a-z0-9_\-.+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-z0-9-]+\.?)+))([a-z]{2,4}|[0-9]{1,3})(]?)/gi, username: /(user( ?name)?|login): \S+/gi, password: /(pass(word|phrase)?|secret): \S+/gi, credentials: /(login( cred(ential)?s| info(rmation)?)?|cred(ential)?s) ?:\s*\S+\s+\/?\s*\S+/gi, company: /([A-Z&][\w,]* )+(I[Nn][Cc](orporated)?|C[Oo](rp(oration)?)?|LLP|llc|LLC|plc|gmbh)\.?(\b|$)/g, salutation: /(^|\n(\s+)?)(dear|hi|hey|hello|greetings) ([^,:;\s]+(,? )?){1,5}[,;\n]/gi, - valediction: /(thanks|cheers|sincerely|regards|respectfully|best|best regards|yours truly)\s*,?\n\s*([\w&]+( )?){1,5}/gi, + valediction: /([Tt]hank(s| you)( for [^!,.]+| again)?|[Cc]heers|[Ss]incerely|[Rr]egards|[Rr]espectfully|[Bb]est|[Bb]est regards|[Yy]ours truly)\s*[!,.]?\s*([A-Z&]([\w&]+)?\.?( )?)+[^a-z]*$/g, + digits: /\d+/ }; diff --git a/test/index.test.js b/test/index.test.js index eede696..71c91f6 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -38,8 +38,8 @@ defineTest('index.js', function (Redactor) { it('should replace credit card numbers', function () { redactor.redact('my card: 1234 5678 8765 4321.').should.equal('my card: CREDIT_CARD_NUMBER.'); - redactor.redact('my 2nd card: 1234-5678-8765-4321.').should.equal('my 2nd card: CREDIT_CARD_NUMBER.'); - redactor.redact('my 3rd card: 1234567887654321.').should.equal('my 3rd card: CREDIT_CARD_NUMBER.'); + redactor.redact('my 2nd card: 1234-5678-8765-4321.').should.equal('my DIGITSnd card: CREDIT_CARD_NUMBER.'); + redactor.redact('my 3rd card: 1234567887654321.').should.equal('my DIGITSrd card: CREDIT_CARD_NUMBER.'); }); it('should replace phone numbers', function () { @@ -69,7 +69,7 @@ defineTest('index.js', function (Redactor) { verify([ 'Oh no worries I live right down the street and up the boulevard', 'There is no way that I will pay for that circle in court', - 'I have thought of 1000 ways to finish that drive', + 'I have thought of many ways to finish that drive', ]); }); @@ -138,7 +138,7 @@ defineTest('index.js', function (Redactor) { } }); - redactor.redact('my CC is 1234567812345678').should.equal('my CC is XXXXXXXXXXXX5678'); + redactor.redact('my CC is 1234567812345678').should.equal('my CC is XXXXXXXXXXXXDIGITS'); redactor.redact('David Johnson lives in 90210').should.equal('FULL_NAME lives in ZIPCODE'); });