-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: 모든 페이지 기능 보안 및 리팩토링 #137
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
Changes from all commits
bd69009
434d94d
8a7e0be
232da5c
ce77052
e9a2c29
545f622
4eb7c2a
245b031
3e84b10
f5cd92d
fd152f5
6a846d1
a9984f8
d582277
e26744d
eefd505
50d2a27
1aa4ee3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,7 @@ | ||||||||||||||||||||||||||||||||
| const stripHtml = (html: string): string => { | ||||||||||||||||||||||||||||||||
| const tmp = document.createElement('div'); | ||||||||||||||||||||||||||||||||
| tmp.innerHTML = html; | ||||||||||||||||||||||||||||||||
| return tmp.textContent || tmp.innerText || ''; | ||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+5
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 HTML 태그 제거 함수의 안전성을 개선하세요. 이 함수는 HTML 문자열에서 태그를 제거하는 용도로 잘 구현되었으나, 다음과 같은 개선사항이 있습니다:
다음과 같이 개선할 수 있습니다: -const stripHtml = (html: string): string => {
+const stripHtml = (html: string | null | undefined): string => {
+ if (html == null) return '';
+
+ // 간단한 HTML에 대해서는 정규식 사용 (더 효율적)
+ // return html.replace(/<[^>]*>?/g, '');
+
const tmp = document.createElement('div');
tmp.innerHTML = html;
return tmp.textContent || tmp.innerText || '';
};DOM 기반 방식은 HTML 엔티티를 올바르게 디코딩하는 이점이 있으므로, 정규식 접근 방식은 선택적으로 적용하세요. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| export default stripHtml; | ||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.