Skip to content
Open
Changes from 1 commit
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
11 changes: 5 additions & 6 deletions app/lib/database/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import XRegExp from 'xregexp';
import { slugify } from 'transliteration';

// Matches letters from any alphabet and numbers
const likeStringRegex = XRegExp('[^\\p{L}\\p{Nd}]', 'g');
Expand All @@ -10,10 +8,11 @@ export const sanitizeLikeString = (str?: string): string | undefined => str?.rep
// slugifyLikeString('測試123') => 'ce-shi-123'
// slugifyLikeString('テスト123') => 'tesuto123'
export const slugifyLikeString = (str?: string) => {
if (!str) return '';
str?.replace(likeStringRegex, '_');
const slugified = slugify(str);
return slugified;
if (!str) return '';
const sanitized = str.replace(likeStringRegex, '_');
const slugified = slugify(sanitized);
return slugified;
};


export const sanitizer = (r: object): object => r;