From 3dc198aca71e585d23d0b13133138144b53eb957 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Fri, 29 Dec 2023 14:32:11 -0800 Subject: [PATCH] [find-and-replace] Fix `capitalize` utility --- packages/find-and-replace/lib/project/util.coffee | 5 ++++- packages/find-and-replace/package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/find-and-replace/lib/project/util.coffee b/packages/find-and-replace/lib/project/util.coffee index 17f146831..697db6b93 100644 --- a/packages/find-and-replace/lib/project/util.coffee +++ b/packages/find-and-replace/lib/project/util.coffee @@ -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) -> diff --git a/packages/find-and-replace/package.json b/packages/find-and-replace/package.json index b1206516c..1c06bab84 100644 --- a/packages/find-and-replace/package.json +++ b/packages/find-and-replace/package.json @@ -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'." } }