File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed
Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -8,12 +8,12 @@ func (this *phoneRedaction) clear() {
88}
99func (this * phoneRedaction ) match (input []byte ) {
1010 var previousBreak byte
11- for i := 0 ; i < len ( input ) - 1 ; i ++ {
11+ for i , val := range input {
1212 if i < len (this .used )- 1 && this .used [i ] {
1313 this .resetCount (i )
1414 continue
1515 }
16- if isNumeric (input [ i ] ) {
16+ if isNumeric (val ) {
1717 this .numericLength ++
1818 this .length ++
1919 switch {
@@ -28,7 +28,7 @@ func (this *phoneRedaction) match(input []byte) {
2828 continue
2929 }
3030 if i < len (input )- 1 {
31- this .validateBreaks (input [ i ] , previousBreak , i )
31+ this .validateBreaks (val , previousBreak , i )
3232 previousBreak = input [i ]
3333 }
3434 }
Original file line number Diff line number Diff line change @@ -152,6 +152,7 @@ func TestRedactEmail_Invalid_NoRedaction(t *testing.T) {
152152func TestRedactPhone_Valid_Redaction (t * testing.T ) {
153153 t .Parallel ()
154154 redaction := New ()
155+
155156 assertRedaction (t , redaction ,
156157 "801-111-1111 +1(801)111-1111 taco" ,
157158 "************ +************** taco" ,
@@ -172,6 +173,10 @@ func TestRedactPhone_Valid_Redaction(t *testing.T) {
172173 "Blah 801-111-1111 and (801) 111-1111 +1(801)111-1111 taco" ,
173174 "Blah ************ and (801) 111-1111 +************** taco" ,
174175 )
176+ assertRedaction (t , redaction ,
177+ "1111|801-111-1111" ,
178+ "1111|************" ,
179+ )
175180}
176181func TestRedactPhone_Invalid_NoRedaction (t * testing.T ) {
177182 t .Parallel ()
@@ -197,6 +202,10 @@ func TestRedactSSN_Valid_Redaction(t *testing.T) {
197202 "Blah 123-12-1234." ,
198203 "Blah ***********." ,
199204 )
205+ assertRedaction (t , redaction ,
206+ "Blah|123-12-1234" ,
207+ "Blah|***********" ,
208+ )
200209 assertRedaction (t , redaction ,
201210 "123 12 1234 taco" ,
202211 "*********** taco" ,
Original file line number Diff line number Diff line change @@ -6,12 +6,12 @@ func (this *ssnRedaction) clear() {
66 this .breakLength = 0
77}
88func (this * ssnRedaction ) match (input []byte ) {
9- for i := 0 ; i < len ( input ) - 1 ; i ++ {
9+ for i , val := range input {
1010 if i < len (this .used )- 1 && this .used [i ] {
1111 this .resetCount (i )
1212 continue
1313 }
14- if isNumeric (input [ i ] ) {
14+ if isNumeric (val ) {
1515 this .length ++
1616 switch {
1717 case this .length < MaxSSNLength_WithBreaks && this .breakLength <= MaxSSNBreakLength :
@@ -25,7 +25,7 @@ func (this *ssnRedaction) match(input []byte) {
2525 continue
2626 }
2727 if i < len (input )- 1 {
28- this .validateBreaks (input [ i ] , i )
28+ this .validateBreaks (val , i )
2929 }
3030 }
3131 this .resetCount (0 )
You can’t perform that action at this time.
0 commit comments