scan-flow: geolocation scan, location-aware SMS throttle (log sender), finder contact, sms_enabled toggle, branding — 19/19 phase-2 scenarios pass
This commit is contained in:
21
frontend/internal/sms/normalize.go
Normal file
21
frontend/internal/sms/normalize.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package sms
|
||||
|
||||
import "strings"
|
||||
|
||||
// NormalizeAU normalises a phone number to international AU format without a
|
||||
// leading '+' or zero:
|
||||
//
|
||||
// "+61432374487" -> "61432374487"
|
||||
// "0432374487" -> "61432374487"
|
||||
func NormalizeAU(phone string) string {
|
||||
s := strings.Map(func(r rune) rune {
|
||||
if r >= '0' && r <= '9' {
|
||||
return r
|
||||
}
|
||||
return -1
|
||||
}, phone)
|
||||
if strings.HasPrefix(s, "0") && len(s) >= 10 {
|
||||
s = "61" + s[1:]
|
||||
}
|
||||
return s
|
||||
}
|
||||
Reference in New Issue
Block a user