Files
fabric_trade_server/dist/common/utils/phone.js
T
mohmdsdgandCursor cbcea58e94 Deploy via committed dist: local Nest build, server runs with .env
Build on the developer machine without Docker, commit dist/, and run on the server with Dockerfile.dist plus compose env_file.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-05 21:35:22 +03:30

24 lines
805 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizePhone = normalizePhone;
exports.isValidPhone = isValidPhone;
exports.toEnglishDigits = toEnglishDigits;
function normalizePhone(raw) {
let digits = raw.replace(/\D/g, '');
if (digits.startsWith('98') && digits.length === 12) {
digits = `0${digits.slice(2)}`;
}
if (digits.length === 10 && digits.startsWith('9')) {
digits = `0${digits}`;
}
return digits;
}
function isValidPhone(phone) {
return /^09\d{9}$/.test(phone);
}
function toEnglishDigits(value) {
return value
.replace(/[۰-۹]/g, (d) => String('۰۱۲۳۴۵۶۷۸۹'.indexOf(d)))
.replace(/[٠-٩]/g, (d) => String('٠١٢٣٤٥٦٧٨٩'.indexOf(d)));
}
//# sourceMappingURL=phone.js.map