Skip to content

Conversation

@subhu339
Copy link

@subhu339 subhu339 commented Dec 14, 2025

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)

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

I have read the CONTRIBUTING doc

I have signed the CLA

Lint and unit tests pass locally with my changes

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

Summary by CodeRabbit

  • Bug Fixes
    • Improved input sanitization to ensure special characters are properly handled in text processing operations, enhancing data consistency and reliability.

✏️ Tip: You can customize this high-level summary in your review settings.

@CLAassistant
Copy link

CLAassistant commented Dec 14, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ subhu339
❌ Yahia786
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 14, 2025

Walkthrough

The slugifyLikeString function in app/lib/database/utils.ts was refactored to explicitly sanitize input before slugification. The function now creates an intermediate sanitized string by replacing non-alphanumeric characters with underscores using likeStringRegex, then applies slugify to the result, improving code clarity without changing the method signature or return type.

Changes

Cohort / File(s) Summary
Input Sanitization Refactoring
app/lib/database/utils.ts
Updated slugifyLikeString function to add explicit sanitization step before slugification. Introduced intermediate variables (sanitized, slugified) for clarity. Sanitization now explicitly replaces non-letter/non-digit characters using likeStringRegex before applying slugify. Preserves early return for falsy input.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single-file change affecting one function with straightforward refactoring logic
  • Verify that likeStringRegex pattern correctly captures intended sanitization intent
  • Confirm that the intermediate sanitization step produces expected output before and after slugification

Poem

🐰 A rabbit's delight, when code flows clear,
Sanitizing first, no need to fear!
Underscores dance where odd chars hide,
Then slugify with confidence, side by side! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: sanitizing input in slugifyLikeString before slugification, which aligns with the core purpose of the modification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 likeStringRegex replaces non-alphanumeric characters with underscores, which serve as separators for the slugify function. 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.

📥 Commits

Reviewing files that changed from the base of the PR and between bddcf52 and 6fa9143.

📒 Files selected for processing (1)
  • app/lib/database/utils.ts (1 hunks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants