Skip to content

Commit

Permalink
feat: support for redacting URLs (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
JaredBett authored and justbbetter committed Aug 1, 2017
1 parent e9cb4b9 commit 6168a62
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
18 changes: 3 additions & 15 deletions lib/firstNames.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@
"barbar",
"barbara",
"barbera",
"barbie",
"barbra",
"barrie",
"basilia",
Expand Down Expand Up @@ -869,7 +868,6 @@
"dayna",
"daysi",
"deadra",
"dean",
"deana",
"deandra",
"deandrea",
Expand Down Expand Up @@ -994,7 +992,6 @@
"donella",
"donetta",
"donette",
"dong",
"donita",
"donna",
"donnetta",
Expand Down Expand Up @@ -1275,7 +1272,6 @@
"florentina",
"floretta",
"floria",
"florida",
"florinda",
"florine",
"florrie",
Expand All @@ -1295,7 +1291,6 @@
"francisca",
"francisco",
"francoise",
"frank",
"frankie",
"fransisca",
"fred",
Expand Down Expand Up @@ -1557,7 +1552,6 @@
"jacelyn",
"jacinda",
"jacinta",
"jack",
"jackeline",
"jackelyn",
"jacki",
Expand Down Expand Up @@ -2423,7 +2417,6 @@
"lynne",
"lynnette",
"lynsey",
"ma 50",
"mabel",
"mabelle",
"mable",
Expand Down Expand Up @@ -2818,7 +2811,6 @@
"myrtis",
"myrtle",
"myung",
"nada",
"nadene",
"nadia",
"nadine",
Expand All @@ -2844,6 +2836,7 @@
"natalya",
"natasha",
"natashia",
"nate",
"nathalie",
"natisha",
"natividad",
Expand Down Expand Up @@ -2872,7 +2865,6 @@
"nettie",
"neva",
"nevada",
"nga",
"ngan",
"ngoc",
"nguyet",
Expand Down Expand Up @@ -2924,7 +2916,6 @@
"norma",
"norman",
"nubia",
"numbers",
"nydia",
"nyla",
"obdulia",
Expand All @@ -2946,6 +2937,7 @@
"olivia",
"ollie",
"olympia",
"omar",
"oneida",
"onie",
"onita",
Expand Down Expand Up @@ -3069,6 +3061,7 @@
"raylene",
"raymond",
"raymonde",
"raymund",
"rayna",
"rea",
"reagan",
Expand Down Expand Up @@ -3457,7 +3450,6 @@
"sixta",
"skye",
"slyvia",
"so 10",
"socorro",
"sofia",
"soila",
Expand Down Expand Up @@ -3504,13 +3496,11 @@
"stevie",
"suanne",
"sudie",
"sue",
"sueann",
"suellen",
"suk",
"sulema",
"sumiko",
"sunday",
"sunni",
"susan",
"susana",
Expand Down Expand Up @@ -3804,7 +3794,6 @@
"venice",
"venita",
"vennie",
"venus",
"veola",
"vera",
"verda",
Expand Down Expand Up @@ -3837,7 +3826,6 @@
"vicki",
"vickie",
"vicky",
"victor",
"victoria",
"victorina",
"vida",
Expand Down
3 changes: 2 additions & 1 deletion lib/patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ module.exports = {
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: /([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+/g
digits: /\d+/g,
url: /([^\s:/?#]+):\/\/([^/?#\s]*)([^?#\s]*)(\?([^#\s]*))?(#([^\s]*))?\b/
};
14 changes: 14 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,18 @@ defineTest('index.js', function (Redactor) {
redactor.redact('codeA: 123, codeB: 678').should.equal('codeA: DIGITS, codeB: DIGITS');
});

it('should replace URLs', function () {
redactor.redact('My homepage is http://example.com').should.equal('My homepage is URL');
redactor.redact('ip http://127.0.01/example.html test').should.equal('ip URL test');
redactor.redact('custom protocol myapp://example.com').should.equal('custom protocol URL');
redactor.redact('Reset password url is https://example.com/reset/password/12345').should.equal('Reset password url is URL');
redactor.redact('complex http://user@pass:example.com:8080/reset/password/12345?foo=bar&hi=there#/app works?').should.equal('complex URL works?');
redactor.redact('before http://www.example.com after').should.equal('before URL after');
redactor.redact('before http://www.example.com:123 after').should.equal('before URL after');
redactor.redact('before http://www.example.com/foo after').should.equal('before URL after');
redactor.redact('before http://www.example.com/foo/bar after').should.equal('before URL after');
redactor.redact('before http://www.example.com/foo/bar?foo=bar after').should.equal('before URL after');
redactor.redact('before http://www.example.com/foo/bar?foo=bar#/foo/bar after').should.equal('before URL after');
});

});

0 comments on commit 6168a62

Please sign in to comment.