feat: Improve slug generation and test tolerance
- Improve slug generation by replacing non-alphanumeric characters in titles - Optimize pinyin generation by moving character replacement to after its execution
This commit is contained in:
parent
c151d6d2f7
commit
6f95187244
|
|
@ -33,8 +33,7 @@ export const getNoteSlug = (note: NoteEntity) => {
|
|||
}
|
||||
|
||||
export const getDefaultSlug = (title: string, id?: string) => {
|
||||
title = title.replace(/[^a-zA-Z0-9\s]/g, "")
|
||||
return (
|
||||
let generated =
|
||||
pinyin(title as string, {
|
||||
style: pinyin.STYLE_NORMAL,
|
||||
compact: true,
|
||||
|
|
@ -45,5 +44,7 @@ export const getDefaultSlug = (title: string, id?: string) => {
|
|||
?.replace(/\s+/g, "-") ||
|
||||
id?.replace(`local-`, "") ||
|
||||
""
|
||||
)
|
||||
generated = generated.replace(/[^a-zA-Z0-9\s-_]/g, "")
|
||||
|
||||
return generated
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue