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() {
8
8
}
9
9
func (this * phoneRedaction ) match (input []byte ) {
10
10
var previousBreak byte
11
- for i := 0 ; i < len ( input ) - 1 ; i ++ {
11
+ for i , val := range input {
12
12
if i < len (this .used )- 1 && this .used [i ] {
13
13
this .resetCount (i )
14
14
continue
15
15
}
16
- if isNumeric (input [ i ] ) {
16
+ if isNumeric (val ) {
17
17
this .numericLength ++
18
18
this .length ++
19
19
switch {
@@ -28,7 +28,7 @@ func (this *phoneRedaction) match(input []byte) {
28
28
continue
29
29
}
30
30
if i < len (input )- 1 {
31
- this .validateBreaks (input [ i ] , previousBreak , i )
31
+ this .validateBreaks (val , previousBreak , i )
32
32
previousBreak = input [i ]
33
33
}
34
34
}
Original file line number Diff line number Diff line change @@ -152,6 +152,7 @@ func TestRedactEmail_Invalid_NoRedaction(t *testing.T) {
152
152
func TestRedactPhone_Valid_Redaction (t * testing.T ) {
153
153
t .Parallel ()
154
154
redaction := New ()
155
+
155
156
assertRedaction (t , redaction ,
156
157
"801-111-1111 +1(801)111-1111 taco" ,
157
158
"************ +************** taco" ,
@@ -172,6 +173,10 @@ func TestRedactPhone_Valid_Redaction(t *testing.T) {
172
173
"Blah 801-111-1111 and (801) 111-1111 +1(801)111-1111 taco" ,
173
174
"Blah ************ and (801) 111-1111 +************** taco" ,
174
175
)
176
+ assertRedaction (t , redaction ,
177
+ "1111|801-111-1111" ,
178
+ "1111|************" ,
179
+ )
175
180
}
176
181
func TestRedactPhone_Invalid_NoRedaction (t * testing.T ) {
177
182
t .Parallel ()
@@ -197,6 +202,10 @@ func TestRedactSSN_Valid_Redaction(t *testing.T) {
197
202
"Blah 123-12-1234." ,
198
203
"Blah ***********." ,
199
204
)
205
+ assertRedaction (t , redaction ,
206
+ "Blah|123-12-1234" ,
207
+ "Blah|***********" ,
208
+ )
200
209
assertRedaction (t , redaction ,
201
210
"123 12 1234 taco" ,
202
211
"*********** taco" ,
Original file line number Diff line number Diff line change @@ -6,12 +6,12 @@ func (this *ssnRedaction) clear() {
6
6
this .breakLength = 0
7
7
}
8
8
func (this * ssnRedaction ) match (input []byte ) {
9
- for i := 0 ; i < len ( input ) - 1 ; i ++ {
9
+ for i , val := range input {
10
10
if i < len (this .used )- 1 && this .used [i ] {
11
11
this .resetCount (i )
12
12
continue
13
13
}
14
- if isNumeric (input [ i ] ) {
14
+ if isNumeric (val ) {
15
15
this .length ++
16
16
switch {
17
17
case this .length < MaxSSNLength_WithBreaks && this .breakLength <= MaxSSNBreakLength :
@@ -25,7 +25,7 @@ func (this *ssnRedaction) match(input []byte) {
25
25
continue
26
26
}
27
27
if i < len (input )- 1 {
28
- this .validateBreaks (input [ i ] , i )
28
+ this .validateBreaks (val , i )
29
29
}
30
30
}
31
31
this .resetCount (0 )
You can’t perform that action at this time.
0 commit comments