Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 2x 30x 27x 27x 27x 27x | /** Normalize to a consistent representation (approx. E.164-like):
* - Keep leading '+' if present
* - Remove spaces, dashes, parentheses
* - Remove any non-digit characters except leading '+'
* - You can adapt to your locale/validation as needed
*/
export function normalize(phoneRaw: string): string {
if (!phoneRaw) return "";
const trimmed = phoneRaw.trim();
const hasPlus = trimmed.startsWith("+");
const digitsOnly = trimmed.replace(/[^\d]/g, "");
return hasPlus ? `+${digitsOnly}` : digitsOnly; // store either "+855123..." or "0123..."
}
|