Skip to content

Commit 6168a62

Browse files
JaredBettjustbbetter
authored andcommitted
feat: support for redacting URLs (#8)
1 parent e9cb4b9 commit 6168a62

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

lib/firstNames.json

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@
329329
"barbar",
330330
"barbara",
331331
"barbera",
332-
"barbie",
333332
"barbra",
334333
"barrie",
335334
"basilia",
@@ -869,7 +868,6 @@
869868
"dayna",
870869
"daysi",
871870
"deadra",
872-
"dean",
873871
"deana",
874872
"deandra",
875873
"deandrea",
@@ -994,7 +992,6 @@
994992
"donella",
995993
"donetta",
996994
"donette",
997-
"dong",
998995
"donita",
999996
"donna",
1000997
"donnetta",
@@ -1275,7 +1272,6 @@
12751272
"florentina",
12761273
"floretta",
12771274
"floria",
1278-
"florida",
12791275
"florinda",
12801276
"florine",
12811277
"florrie",
@@ -1295,7 +1291,6 @@
12951291
"francisca",
12961292
"francisco",
12971293
"francoise",
1298-
"frank",
12991294
"frankie",
13001295
"fransisca",
13011296
"fred",
@@ -1557,7 +1552,6 @@
15571552
"jacelyn",
15581553
"jacinda",
15591554
"jacinta",
1560-
"jack",
15611555
"jackeline",
15621556
"jackelyn",
15631557
"jacki",
@@ -2423,7 +2417,6 @@
24232417
"lynne",
24242418
"lynnette",
24252419
"lynsey",
2426-
"ma 50",
24272420
"mabel",
24282421
"mabelle",
24292422
"mable",
@@ -2818,7 +2811,6 @@
28182811
"myrtis",
28192812
"myrtle",
28202813
"myung",
2821-
"nada",
28222814
"nadene",
28232815
"nadia",
28242816
"nadine",
@@ -2844,6 +2836,7 @@
28442836
"natalya",
28452837
"natasha",
28462838
"natashia",
2839+
"nate",
28472840
"nathalie",
28482841
"natisha",
28492842
"natividad",
@@ -2872,7 +2865,6 @@
28722865
"nettie",
28732866
"neva",
28742867
"nevada",
2875-
"nga",
28762868
"ngan",
28772869
"ngoc",
28782870
"nguyet",
@@ -2924,7 +2916,6 @@
29242916
"norma",
29252917
"norman",
29262918
"nubia",
2927-
"numbers",
29282919
"nydia",
29292920
"nyla",
29302921
"obdulia",
@@ -2946,6 +2937,7 @@
29462937
"olivia",
29472938
"ollie",
29482939
"olympia",
2940+
"omar",
29492941
"oneida",
29502942
"onie",
29512943
"onita",
@@ -3069,6 +3061,7 @@
30693061
"raylene",
30703062
"raymond",
30713063
"raymonde",
3064+
"raymund",
30723065
"rayna",
30733066
"rea",
30743067
"reagan",
@@ -3457,7 +3450,6 @@
34573450
"sixta",
34583451
"skye",
34593452
"slyvia",
3460-
"so 10",
34613453
"socorro",
34623454
"sofia",
34633455
"soila",
@@ -3504,13 +3496,11 @@
35043496
"stevie",
35053497
"suanne",
35063498
"sudie",
3507-
"sue",
35083499
"sueann",
35093500
"suellen",
35103501
"suk",
35113502
"sulema",
35123503
"sumiko",
3513-
"sunday",
35143504
"sunni",
35153505
"susan",
35163506
"susana",
@@ -3804,7 +3794,6 @@
38043794
"venice",
38053795
"venita",
38063796
"vennie",
3807-
"venus",
38083797
"veola",
38093798
"vera",
38103799
"verda",
@@ -3837,7 +3826,6 @@
38373826
"vicki",
38383827
"vickie",
38393828
"vicky",
3840-
"victor",
38413829
"victoria",
38423830
"victorina",
38433831
"vida",

lib/patterns.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ module.exports = {
2020
company: /([A-Z&][\w,]* )+(I[Nn][Cc](orporated)?|C[Oo](rp(oration)?)?|LLP|llc|LLC|plc|gmbh)\.?(\b|$)/g,
2121
salutation: /(^|\n(\s+)?)(dear|hi|hey|hello|greetings) ([^,:;\s]+(,? )?){1,5}[,;\n]/gi,
2222
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,
23-
digits: /\d+/g
23+
digits: /\d+/g,
24+
url: /([^\s:/?#]+):\/\/([^/?#\s]*)([^?#\s]*)(\?([^#\s]*))?(#([^\s]*))?\b/
2425
};

test/index.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,18 @@ defineTest('index.js', function (Redactor) {
167167
redactor.redact('codeA: 123, codeB: 678').should.equal('codeA: DIGITS, codeB: DIGITS');
168168
});
169169

170+
it('should replace URLs', function () {
171+
redactor.redact('My homepage is http://example.com').should.equal('My homepage is URL');
172+
redactor.redact('ip http://127.0.01/example.html test').should.equal('ip URL test');
173+
redactor.redact('custom protocol myapp://example.com').should.equal('custom protocol URL');
174+
redactor.redact('Reset password url is https://example.com/reset/password/12345').should.equal('Reset password url is URL');
175+
redactor.redact('complex http://user@pass:example.com:8080/reset/password/12345?foo=bar&hi=there#/app works?').should.equal('complex URL works?');
176+
redactor.redact('before http://www.example.com after').should.equal('before URL after');
177+
redactor.redact('before http://www.example.com:123 after').should.equal('before URL after');
178+
redactor.redact('before http://www.example.com/foo after').should.equal('before URL after');
179+
redactor.redact('before http://www.example.com/foo/bar after').should.equal('before URL after');
180+
redactor.redact('before http://www.example.com/foo/bar?foo=bar after').should.equal('before URL after');
181+
redactor.redact('before http://www.example.com/foo/bar?foo=bar#/foo/bar after').should.equal('before URL after');
182+
});
183+
170184
});

0 commit comments

Comments
 (0)