8 lines
303 B
TypeScript
8 lines
303 B
TypeScript
/** Digits only. Drops a leading 0 or 91 so the same mobile is one customer. */
|
|
export function normalizePhone(raw: string): string {
|
|
let d = raw.replace(/\D/g, "");
|
|
if (d.length === 12 && d.startsWith("91")) d = d.slice(2);
|
|
if (d.length === 11 && d.startsWith("0")) d = d.slice(1);
|
|
return d;
|
|
}
|