From 1f4c232784765d59c3e64eba454557f2bc94319e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 29 Dec 2020 15:20:08 +0100 Subject: [PATCH] Camel Case Fixed --- .../UI/Spaces/Docs-Space/DocsSpace.js | 2 +- Projects/Superalgos/UI/Utilities/Strings.js | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js index 1a1142624..64f2d4aa6 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js @@ -3577,7 +3577,7 @@ function newSuperalgosDocSpace() { function addBold(text) { let splittedText = text.split(':') - if (text.indexOf(':' >= 0)) { + if (text.indexOf(':') >= 0) { return '' + text.substring(0, text.indexOf(':') + 1) + '' + text.substring(text.indexOf(':') + 1, text.length) } else { return text diff --git a/Projects/Superalgos/UI/Utilities/Strings.js b/Projects/Superalgos/UI/Utilities/Strings.js index 7e67f03a4..f4cd341f3 100644 --- a/Projects/Superalgos/UI/Utilities/Strings.js +++ b/Projects/Superalgos/UI/Utilities/Strings.js @@ -7,11 +7,23 @@ function newSuperalgosUtilitiesStrings() { return thisObject function fromCamelCaseToUpperWithSpaces(text) { - let result = text.replace( /([A-Z])/g, " $1" ); + let result = text.replace(/([A-Z])/g, " $1"); return result.charAt(0).toUpperCase() + result.slice(1); - } + } function isCamelCase(text) { - return /^([a-z]+)(([A-Z]([a-z]+))+)$/.test(text) - } + /* + We are not only going to detect standard Camel Case, but also + we will accept strings with numbers and dots, so that + object paths test positive. + */ + const result = /^[A-Za-z0-9.]+$/.test(text) + if (result === false) { return false } + + let character = text[0] + if (character !== character.toLowerCase()) { + return false + } + return true + } } \ No newline at end of file