Merged
Conversation
Member
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
Member
Author
|
의견 부탁드려용~ |
klmhyeonwoo
approved these changes
Sep 10, 2025
| }, | ||
| ]; | ||
|
|
||
| export const formatPhoneNumber = (phoneNumber: string): string => { |
Member
There was a problem hiding this comment.
continue를 사용하지 않고 아래와 같이 find 메서드를 사용하는 방법도 있을 것 같아요!
이 함수.. 너무너무 유용하게 잘 쓸 것 같은데요.. 너무너무 고생하셨습니다 (:
export const formatPhoneNumber = (phoneNumber: string): string => {
if (!phoneNumber) return "";
const digitsOnly = phoneNumber.replace(/\D/g, "");
const matched = formatRules.find(
(r) => (!r.prefix || digitsOnly.startsWith(r.prefix)) && digitsOnly.length === r.length
);
return matched ? digitsOnly.replace(matched.format, matched.replacement) : digitsOnly;
};There was a problem hiding this comment.
피드백 감사합니다..!!
find라는 키워드가 들어가면서 무엇을 하려는지 더 명확한 느낌도 있는 것 같아요!
Member
|
|
Member
Author
앗..! 바로 추가했습니다! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
프론트엔드에서 흔히 사용되는 전화번호 자동 하이픈(-) 추가 기능을 구현한
formatPhoneNumber유틸리티 함수를 추가합니다.다양한 케이스에 대응할 수 있도록 함수를 구현하고, vitest를 이용한 테스트 코드를 작성하여 안정성을 높였습니다.
주요 변경 사항
formatPhoneNumber함수 신규 구현close #35