Skip to content

Cannot read .toUpperCase() on undefined (or something like that) #19

@tjerman

Description

@tjerman

This line fails on part[0].toUpperCase() called by this from here from here errors with Cannot read properties of undefined (reading 'toUpperCase') in case the collection starts with an _ (example __backup_something_something).

Perhaps something along the lines of this -- remove all prefix _ and remove duplicate _

function upperCamelCase(value: string) {
    return value.replace(/^_+/, '').replace(/_+/g, '_').split('_')
        .map(part => part[0].toUpperCase() + part.substring(1).toLowerCase())
        .join('');
}

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