260716_02_ENH: 프로젝트에 발신 번호추가 및 리다이렉트 url, api 수정

This commit is contained in:
2026-07-16 14:10:42 +09:00
parent 36c7b41191
commit 7275c77db0
13 changed files with 153 additions and 41 deletions

22
src/utils/phone.ts Normal file
View File

@@ -0,0 +1,22 @@
// 특수/대표번호(15XX, 16XX, 18XX 등): 지역번호 없이 4자리-4자리
const SPECIAL_NUMBER_PREFIX = /^(15|16|18)\d{2}/;
export const formatKoreanPhoneNumber = (value: string): string => {
const digits = value.replace(/\D/g, "");
if (SPECIAL_NUMBER_PREFIX.test(digits) && digits.length === 8) {
return `${digits.slice(0, 4)}-${digits.slice(4)}`;
}
if (digits.startsWith("02")) {
if (digits.length === 9) return `${digits.slice(0, 2)}-${digits.slice(2, 5)}-${digits.slice(5)}`;
if (digits.length === 10) return `${digits.slice(0, 2)}-${digits.slice(2, 6)}-${digits.slice(6)}`;
return value;
}
// 010/011~019(휴대폰), 070(인터넷전화), 031~064(지역번호) 등 3자리 국번
if (digits.length === 10) return `${digits.slice(0, 3)}-${digits.slice(3, 6)}-${digits.slice(6)}`;
if (digits.length === 11) return `${digits.slice(0, 3)}-${digits.slice(3, 7)}-${digits.slice(7)}`;
return value;
};