Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/lib/database/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,10 @@ describe('slugifyLikeString', () => {
const textSlugified = 'tesuto123';
expect(utils.slugifyLikeString(textToSlugify)).toBe(textSlugified);
});
test('slugify with special characters - should sanitize before slugifying', () => {
// Special characters should be replaced with '_' before slugifying
expect(utils.slugifyLikeString('test@#$123')).toBe('test___123');
expect(utils.slugifyLikeString('hello.world!')).toBe('hello_world_');
expect(utils.slugifyLikeString('user-name_123')).toBe('user_name_123');
});
});
4 changes: 2 additions & 2 deletions app/lib/database/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export const sanitizeLikeString = (str?: string): string | undefined => str?.rep
// slugifyLikeString('テスト123') => 'tesuto123'
export const slugifyLikeString = (str?: string) => {
if (!str) return '';
str?.replace(likeStringRegex, '_');
const slugified = slugify(str);
const sanitized = str.replace(likeStringRegex, '_');
const slugified = slugify(sanitized);
return slugified;
};

Expand Down