Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added cyrillic symbols in regexp (#1980) #2154

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/bruno-app/src/utils/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const normalizeFileName = (name) => {
return name;
}

const validChars = /[^\w\s-]/g;
const validChars = /[^\w\s\u0430-\u044f-]/gi;
Copy link
Contributor

@pietrygamat pietrygamat Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, this only adds Cyryllic to basic alphanumeric characters. That still leaves quite a number of characters in other scripts as well as diacritics in Latin, that should be accepted based on the same principle. On top of that I'd argue the \s excludes a few problematic variants of whitespace that should in fact be escaped.

My proposition is the following:
/[^\p{L}\p{N} \.-_]/gu
That is:

  • /gu for full unicode
  • \p{L} - any kind of letter from any script
  • \p{N} - any kind of numeric character in any script
  • \.-_ - a literal whitespace, a dot, a dash and an underscore

Would bruno support that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with expanding that regex to exclude more characters. Also technically that regex variable should probably be called invalidChars.

const formattedName = name.replace(validChars, '-');

return formattedName;
Expand Down