fix
This commit is contained in:
parent
cfe690a40f
commit
691456af87
@ -107,14 +107,21 @@ func maskPhoneNumber(phone *string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
phoneStr := *phone
|
phoneStr := *phone
|
||||||
if len(phoneStr) <= 4 {
|
|
||||||
return strings.Repeat("*", len(phoneStr))
|
// Normalize: replace leading "62" with "0"
|
||||||
|
if strings.HasPrefix(phoneStr, "62") {
|
||||||
|
phoneStr = "0" + phoneStr[2:]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show first 2 and last 2 characters, mask the middle
|
// If phone length <= 8, just mask the middle
|
||||||
start := phoneStr[:2]
|
if len(phoneStr) <= 8 {
|
||||||
end := phoneStr[len(phoneStr)-2:]
|
return phoneStr
|
||||||
middle := strings.Repeat("*", len(phoneStr)-4)
|
}
|
||||||
|
|
||||||
|
// Show first 4 and last 4 characters
|
||||||
|
start := phoneStr[:4]
|
||||||
|
end := phoneStr[len(phoneStr)-4:]
|
||||||
|
middle := strings.Repeat("*", len(phoneStr)-8)
|
||||||
|
|
||||||
return start + middle + end
|
return start + middle + end
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user