-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
export const stripDiacritics = (str) => | ||
str.normalize("NFD").replace(/[\u0300-\u036F]/g, ""); | ||
export function stripDiacritics( | ||
str: string | readonly string[] | undefined | ||
): any { | ||
if (str === undefined) { | ||
return str; | ||
} | ||
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 commentThe 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, ""));
ToolsBiome
|
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.Committable suggestion
Tools
Biome