0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

fix(console): markdown toc links that contain special characters should work (#1543)

This commit is contained in:
Charles Zhao 2022-07-14 17:45:19 +08:00 committed by GitHub
parent e06f8d027e
commit 1b056f125d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,7 +29,11 @@ const Markdown = ({ className, children }: Props) => {
return resolveIdCollision(kebabCaseString, index + 1);
};
const initialKebabCaseString = text.replace(/\s/g, '-').toLowerCase();
const initialKebabCaseString = text
// Remove all symbols and punctuations except for dash and underscore. https://javascript.info/regexp-unicode
.replace(/\p{S}|\p{Pi}|\p{Pf}|\p{Ps}|\p{Pe}|\p{Po}/gu, '')
.replace(/\s+/g, '-')
.toLowerCase();
return resolveIdCollision(initialKebabCaseString);
};