[FIX] modify regex to accept cyrillic characters in page name (#4741)

* modify regex to accept cyrillic characters in page name

* Remove separator regex in order to allow all utf characters

* Disallow special characters
This commit is contained in:
Kaushik Varanasi 2021-06-12 20:35:26 +05:30 committed by GitHub
parent 50e5807e8d
commit 9d6247672a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,11 +110,13 @@ export const flashElementById = (id: string) => {
}; };
export const resolveAsSpaceChar = (value: string, limit?: number) => { export const resolveAsSpaceChar = (value: string, limit?: number) => {
const separatorRegex = /[^\w\s]/; // ensures that all special characters are disallowed
// while allowing all utf-8 characters
const removeSpecialCharsRegex = /`|\~|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\+|\=|\[|\{|\]|\}|\||\\|\'|\<|\,|\.|\>|\?|\/|\""|\;|\:|\s/;
const duplicateSpaceRegex = /\s+/; const duplicateSpaceRegex = /\s+/;
return value return value
.split(separatorRegex) .split(removeSpecialCharsRegex)
.join("") .join(" ")
.split(duplicateSpaceRegex) .split(duplicateSpaceRegex)
.join(" ") .join(" ")
.slice(0, limit || 30); .slice(0, limit || 30);