22 lines
433 B
Go
22 lines
433 B
Go
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
|
|
}
|