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

[find-and-replace] Fix capitalize utility #849

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/find-and-replace/lib/project/util.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ showIf = (condition) ->
else
{display: 'none'}

capitalize = (str) -> str[0].toUpperCase() + str.toLowerCase().slice(1)
capitalize = (str) ->
return '' if str == ''
str[0].toUpperCase() + str.toLowerCase().slice(1)

titleize = (str) -> str.toLowerCase().replace(/(?:^|\s)\S/g, (capital) -> capital.toUpperCase())

preserveCase = (text, reference) ->
Expand Down
2 changes: 1 addition & 1 deletion packages/find-and-replace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
"preserveCaseOnReplace": {
"type": "boolean",
"default": false,
"title": "Preserve case during replace.",
"title": "Preserve Case During Replace",
"description": "Keep the replaced text case during replace: replacing 'user' with 'person' will replace 'User' with 'Person' and 'USER' with 'PERSON'."
}
}
Expand Down
Loading