Skip to content

bug: singularize mishandles plurals ending with ['xes', 'sses', 'ches', 'shes'] #19

@kheiner

Description

@kheiner

The conditional as written never slices 'es' since a word cannot end with es and also end with 'x' | 'ch' | 'ss' | 'sh':

if (word.endsWith('es') && ['ch', 'sh', 'ss', 'x'].some((ending) => word.endsWith(ending))) {
return word.slice(0, -2);
}

leaving the word to be handled by:

if (word.endsWith('s') && !word.endsWith('ss') && word.length > 3) {
return word.slice(0, -1);
}

Output

Field Name Current Output Expected Output
boxes Boxe Box
sandwiches Sandwiche Sandwich
dresses Dresse Dress
wishes Wishe Wish

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions