mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-22 06:31:18 +01:00
fix: support name in Chinese [#3211]
This commit is contained in:
parent
ac67c4c0d8
commit
0ac735a1e6
@ -70,13 +70,13 @@ export const safeParseXML = (str, options) => {
|
||||
}
|
||||
};
|
||||
|
||||
// Remove any characters that are not alphanumeric, spaces, hyphens, or underscores
|
||||
// Remove any characters that are not alphanumeric, spaces, hyphens, underscores, or Chinese characters
|
||||
export const normalizeFileName = (name) => {
|
||||
if (!name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
const validChars = /[^\w\s-]/g;
|
||||
const validChars = /[^\w\s\u4e00-\u9fa5-]/g;
|
||||
const formattedName = name.replace(validChars, '-');
|
||||
|
||||
return formattedName;
|
||||
|
@ -14,6 +14,7 @@ describe('common utils', () => {
|
||||
expect(normalizeFileName('hello_world?')).toBe('hello_world-');
|
||||
expect(normalizeFileName('foo/bar/')).toBe('foo-bar-');
|
||||
expect(normalizeFileName('foo\\bar\\')).toBe('foo-bar-');
|
||||
expect(normalizeFileName('hello_world-123中文!@#$%^&*()')).toBe('hello_world-123中文----------');
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user