mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[DevTools] Don't pluralize if already plural (#34870)
In a demo today, `cookies()` showed up as `cookieses`. While adorable, is wrong.
This commit is contained in:
@@ -205,6 +205,27 @@ export function pluralize(word: string): string {
|
||||
return word;
|
||||
}
|
||||
|
||||
// Bail out if it's already plural.
|
||||
switch (word) {
|
||||
case 'men':
|
||||
case 'women':
|
||||
case 'children':
|
||||
case 'feet':
|
||||
case 'teeth':
|
||||
case 'mice':
|
||||
case 'people':
|
||||
return word;
|
||||
}
|
||||
|
||||
if (
|
||||
/(ches|shes|ses|xes|zes)$/i.test(word) ||
|
||||
/[^s]ies$/i.test(word) ||
|
||||
/ves$/i.test(word) ||
|
||||
/[^s]s$/i.test(word)
|
||||
) {
|
||||
return word;
|
||||
}
|
||||
|
||||
switch (word) {
|
||||
case 'man':
|
||||
return 'men';
|
||||
|
||||
Reference in New Issue
Block a user