Skip to content

Commit

Permalink
fix: support name in Chinese [usebruno#3211]
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonxiang committed Oct 21, 2024
1 parent ac67c4c commit 0ac735a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/bruno-app/src/utils/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions packages/bruno-app/src/utils/common/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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中文----------');
});
});

Expand Down

0 comments on commit 0ac735a

Please sign in to comment.