Fix/#99 검색어 하이라이팅 시 정규식 특수문자 입력 에러(SyntaxError) 해결#100
Fix/#99 검색어 하이라이팅 시 정규식 특수문자 입력 에러(SyntaxError) 해결#100leeleeleeleejun merged 3 commits intodevelopfrom
Conversation
- 특수 문자 입력 시 에러 발생으로 인해 특수문자 처리 추가 - 인자 이름 변경
Walkthrough
Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/app/_components/SearchPage/SearchPlaceListItem.tsx (1)
1-16:⚠️ Potential issue | 🟡 MinorSearchPage와의 순환 의존성을
import type으로 해결해야 합니다.
SearchPage가 SearchPlaceListItem을 import하고(line 5), SearchPlaceListItem이 SearchPage에서 BasePlace를 import하는 순환 구조입니다. BasePlace는 type-only export이고 타입 어노테이션으로만 사용되므로,import type으로 명시하여 순환 의존성을 명확히 제거하는 것이 TypeScript 모범 사례입니다.💡 수정 방법
-import { BasePlace } from './SearchPage' +import type { BasePlace } from './SearchPage'
#️⃣연관된 이슈
📝작업 내용
장소 검색 기능 사용 시, 정규표현식 예약어(특수문자) 입력으로 인해 발생하는 버그를 수정했습니다.
1. 검색어 하이라이팅 로직 수정 (highlightWord)
문제 상황
검색창에 [, ( 등 정규식에서 특수한 기능을 담당하는 문자를 입력할 경우, new RegExp() 생성 과정에서 문법 오류(SyntaxError: Invalid regular expression)가 발생되었습니다.
해결 방안
사용자 입력값을 정규식 패턴으로 변환하기 전에, 특수문자를 일반 문자열로 인식하도록 이스케이프(Escape) 처리하는 유틸리티 함수(escapeRegExp)를 적용했습니다.
예시: 사용자가
[입력 시 -> 내부적으로\[로 변환하여 정규식 문법이 아닌 문자[자체로 매칭되도록 수정스크린샷 (선택)
💬리뷰 요구사항(선택)
Summary by CodeRabbit
새로운 기능
개선 사항