Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tsknadaj committed Oct 14, 2024
1 parent 56854d5 commit 97686ad
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
4 changes: 3 additions & 1 deletion gdpr/protect_device_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const (

// ProtectDeviceID hides last two character from passed device id and returns string with protected value
func ProtectDeviceID(val string) string {
if val == "" || strings.ToLower(val) == unknownValue || strings.ToLower(val) == nonAvailableValue {
lowered := strings.ToLower(val)

if val == "" || lowered == unknownValue || lowered == nonAvailableValue {
return val
}

Expand Down
24 changes: 22 additions & 2 deletions gdpr/protect_device_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,35 @@ func Test_ProtectDeviceID(t *testing.T) {
want: "",
},
{
name: "unknown value",
name: "unknown value - lower case",
value: "unknown",
want: "unknown",
},
{
name: "non available value",
name: "unknown value - upper case",
value: "UNKNOWN",
want: "UNKNOWN",
},
{
name: "unknown value - mixed case",
value: "unKNowN",
want: "unKNowN",
},
{
name: "non available value - upper case",
value: "N/A",
want: "N/A",
},
{
name: "non available value - lower case",
value: "n/a",
want: "n/a",
},
{
name: "non available value - mixed case",
value: "n/A",
want: "n/A",
},
{
name: "correct value to protect",
value: "some_value",
Expand Down

0 comments on commit 97686ad

Please sign in to comment.