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>
24 lines
805 B
JavaScript
24 lines
805 B
JavaScript
"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
|