-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Catch more types of search inputs in stripDiacritics #21174
Conversation
Note Reviews pausedUse the following commands to manage reviews:
WalkthroughWalkthroughThe functionality of the Changes
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Additional context usedBiome
Additional comments not posted (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
This comment was marked as off-topic.
This comment was marked as off-topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
if (typeof str === "string") { | ||
return str.normalize("NFD").replace(/[\u0300-\u036F]/g, ""); | ||
} | ||
return str.map((s) => s.normalize("NFD").replace(/[\u0300-\u036F]/g, "")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a safer character class in regular expressions.
The current implementation may lead to issues due to a misleading character class.
- return str.map((s) => s.normalize("NFD").replace(/[\u0300-\u036F]/g, ""));
+ return str.map((s) => s.normalize("NFD").replace(/[\u0300-\u036f]/g, ""));
Committable suggestion was skipped due to low confidence.
Tools
Biome
[error] 10-10: Unexpected combined character in the character class. (lint/suspicious/noMisleadingCharacterClass)
export function stripDiacritics( | ||
str: string | readonly string[] | undefined | ||
): any { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify a more appropriate return type instead of any
.
Using any
as a return type defeats the purpose of TypeScript's static type checking. Consider specifying a more precise type.
- export function stripDiacritics(
- str: string | readonly string[] | undefined
- ): any {
+ export function stripDiacritics(
+ str: string | readonly string[] | undefined
+ ): string | string[] | undefined {
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
export function stripDiacritics( | |
str: string | readonly string[] | undefined | |
): any { | |
export function stripDiacritics( | |
str: string | readonly string[] | undefined | |
): string | string[] | undefined { |
Tools
Biome
[error] 3-3: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
Proposed change
It was reported in the beta channel that the search in the "add integration" dialog no longer functions. Going through, it seems to throw in undefined values and string arrays in the stripDiacritics function as well. Adding support for this makes it work, but drops the performance of the search function.
Type of change
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed:
@coderabbitai pause
Summary by CodeRabbit
New Features
Improvements