-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] 네이버 검색 결과 태그 제거, 카테고리 대분류 추출 #86
Changes from 5 commits
4eb9873
b53ab1c
52321d5
a5a8f3b
a38ff49
c530a9c
2eeec62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ export const useInput = (initialValue = '', validation: string[] = ['https', 'ww | |
|
||
const onChange: ChangeEventHandler<HTMLInputElement> = useCallback((e) => { | ||
const value = e.target.value; | ||
setState(value); | ||
setState(value.trim()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 입력값 트리밍 시점 재고가 필요합니다 onChange 이벤트에서 즉시 트리밍하는 것은 사용자 경험을 해칠 수 있습니다. 사용자가 입력 중에 공백을 사용하는 것이 불가능해집니다. 다음과 같이 onBlur 이벤트에서 트리밍하는 것을 추천드립니다: - setState(value.trim());
+ setState(value); 그리고 onBlur 함수에서 트리밍을 수행: const onBlur = useCallback(() => {
+ setState(state.trim());
if (state.length > 0) {
setIsValid(validation.some((criteria) => state.includes(criteria)));
}
}, [state, validation]);
|
||
}, []); | ||
|
||
const onBlur = useCallback(() => { | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -42,7 +42,7 @@ export const CustomMarker = ({ | |||||||||||||||||||||||||||||||
<object data="${markerIcon}" type="image/svg+xml" style="width: 37px; height: 47px;"></object> | ||||||||||||||||||||||||||||||||
<object data="${categoryIcon}" type="image/svg+xml" style="width: 33px; height: 33px; position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%);"></object> | ||||||||||||||||||||||||||||||||
</button> | ||||||||||||||||||||||||||||||||
<span style="display: block; font-size: 12px; font-weight: 400; color: black; text-align: center; white-space: normal; margin-top: 4px;"> | ||||||||||||||||||||||||||||||||
<span style="display: block; font-size: 12px; font-weight: 600; color: black; text-align: center; white-space: normal; margin-top: 4px;"> | ||||||||||||||||||||||||||||||||
${shouldShowTitle ? title : ''} | ||||||||||||||||||||||||||||||||
</span> | ||||||||||||||||||||||||||||||||
Comment on lines
+45
to
47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 보안 취약점 개선이 필요합니다 문자열 템플릿을 통한 직접적인 HTML 삽입은 XSS 공격에 취약할 수 있습니다. 다음과 같이 HTML 이스케이프 함수를 추가하고 적용하는 것을 추천드립니다: +const escapeHtml = (str: string) => {
+ return str
+ .replace(/&/g, '&')
+ .replace(/</g, '<')
+ .replace(/>/g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''');
+};
<span style="display: block; font-size: 12px; font-weight: 600; color: black; text-align: center; white-space: normal; margin-top: 4px;">
- ${shouldShowTitle ? title : ''}
+ ${shouldShowTitle ? escapeHtml(title) : ''}
</span> 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,17 @@ | ||||||||||||||||||||||||||||||||
import { Place } from '@/types/naver'; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
const removeHtmlTags = (result: string) => { | ||||||||||||||||||||||||||||||||
return result.replace(/<\/?[^>]+(>|$)/g, ''); | ||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
const extractCategory = (category: string) => { | ||||||||||||||||||||||||||||||||
return category.split('>')[0]; | ||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||
Comment on lines
+7
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 카테고리 추출 시 예외 처리가 필요합니다 빈 문자열이나 구분자가 없는 경우에 대한 처리가 없습니다. 다음과 같이 예외 처리를 추가하는 것을 추천드립니다: - return category.split('>')[0];
+ return category?.split('>')?.[0]?.trim() ?? category ?? ''; 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
export const parseSearchResult = (data: Place[]) => { | ||||||||||||||||||||||||||||||||
return data.map((item) => ({ | ||||||||||||||||||||||||||||||||
...item, | ||||||||||||||||||||||||||||||||
title: removeHtmlTags(item.title), | ||||||||||||||||||||||||||||||||
category: typeof item.category === 'string' ? extractCategory(item.category) : '', | ||||||||||||||||||||||||||||||||
})); | ||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||
Comment on lines
+11
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 타입 안전성 강화가 필요합니다
다음과 같이 타입 가드와 필수 필드 검증을 추가하는 것을 추천드립니다: export const parseSearchResult = (data: Place[]) => {
+ if (!Array.isArray(data)) return [];
return data.map((item) => ({
...item,
- title: removeHtmlTags(item.title),
+ title: item.title ? removeHtmlTags(item.title) : '',
category: typeof item.category === 'string' ? extractCategory(item.category) : '',
}));
}; 📝 Committable suggestion
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Typography 스타일이 중복되어 있습니다
Body4 컴포넌트는 이미
text-body4
클래스를 통해 14px 폰트 크기를 정의하고 있습니다. Tailwind 설정에서text-body4
가14px
로 정의되어 있으므로,text-[14px]
클래스는 불필요한 중복입니다. 해당 클래스를 제거하여 Typography 시스템의 일관성을 유지하시기 바랍니다.🔗 Analysis chain
Typography 스타일 중복 확인 필요
Body4 컴포넌트가 이미 기본 폰트 크기를 정의하고 있다면, text-[14px] 클래스는 중복될 수 있습니다. Typography 시스템의 일관성을 위해 확인이 필요합니다.
Let me check the Tailwind configuration to see if
text-body4
class defines a specific font size.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 2007
Script:
Length of output: 785