-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: sanitize slugifyLikeString before slugifying #6847
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
base: develop
Are you sure you want to change the base?
Conversation
|
|
WalkthroughThe Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
app/lib/database/utils.ts (1)
11-14: Sanitization step is necessary—keep as-is; add explicit return type annotation.The sanitization step is not redundant. The
likeStringRegexreplaces non-alphanumeric characters with underscores, which serve as separators for theslugifyfunction. These underscores are then converted to hyphens during slugification. This behavior is intentional and verified by the test suite: the Chinese example'測試123'correctly produces'ce-shi-123'(with hyphens between transliterated characters) rather than'ceshi123'. Without this sanitization, transliterated non-Latin characters would run together without separation.Add explicit return type annotation for type safety:
-export const slugifyLikeString = (str?: string) => { +export const slugifyLikeString = (str?: string): string => { if (!str) return ''; const sanitized = str.replace(likeStringRegex, '_'); const slugified = slugify(sanitized); return slugified; };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
app/lib/database/utils.ts(1 hunks)
Proposed changes
Fix slugifyLikeString to properly sanitize strings before slugifying, preventing special characters from breaking functionality.
Issue(s)
No linked issue (or link the issue if one exists).
How to test or reproduce
Call slugifyLikeString with a string containing special or non-Latin characters, e.g., '測試123' → output should be 'ce-shi-123'.
Screenshots
Types of changes
Bugfix (non-breaking change which fixes an issue)
Checklist
I have read the CONTRIBUTING doc
I have signed the CLA
Lint and unit tests pass locally with my changes
Further comments
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.