Skip to content
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

do not convert words to lower case unless necessary in to pascal #762

Merged
merged 2 commits into from
Feb 5, 2024

Conversation

alissawix
Copy link
Contributor

@alissawix alissawix commented Feb 5, 2024

so that HTTPRequest will stay as is
and myHTTPRequest will become MyHTTPRequest instead of MyHttpRequest

** when upgrading the version in codux delete string util tests

@alissawix alissawix requested review from alisey and daomry February 5, 2024 07:38
return words.join('');
const originalWords = splitIntoWords(str);
const strNoConversionToLower = originalWords.map((word) => capitalizeFirstLetter(word)).join('');
if (new RegExp('[a-z]').test(strNoConversionToLower)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/[a-z]/.test(...)

Copy link
Contributor

@alisey alisey Feb 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess another option would be:

export function toPascalCase(str: string): string {
    if (/^[a-z]+$/i.test(str)) {
        return capitalizeFirstLetter(str);
    }
    // ...
}

(Would work slightly differently with numbers, but handling numbers is weird in general).

@alissawix alissawix merged commit 7bbdc73 into master Feb 5, 2024
6 checks passed
@alissawix alissawix deleted the alissav/fix-to-pascal-case branch February 5, 2024 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants