From 23c6f134bea30acf05323bf92e1bd4e3fa4d27bb Mon Sep 17 00:00:00 2001 From: Niveathika Date: Thu, 6 Jun 2024 14:08:28 +0530 Subject: [PATCH] Disable restore case by default --- ballerina/configurables.bal | 3 +++ ballerina/main.bal | 4 ++++ ballerina/tests/tests.bal | 2 +- changelog.md | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 ballerina/configurables.bal diff --git a/ballerina/configurables.bal b/ballerina/configurables.bal new file mode 100644 index 0000000..c75ad34 --- /dev/null +++ b/ballerina/configurables.bal @@ -0,0 +1,3 @@ + +# This can be used to match case of the given word. Does not work with camel case +configurable boolean tryToRestoreCase = false; diff --git a/ballerina/main.bal b/ballerina/main.bal index 8c2456d..e265792 100644 --- a/ballerina/main.bal +++ b/ballerina/main.bal @@ -122,6 +122,10 @@ function replaceWordWithRules(string word, string token, [regexp:RegExp, Capture } function restoreCase(string word, string token) returns string { + if !tryToRestoreCase { + return token; + } + if word == token { return token; } diff --git a/ballerina/tests/tests.bal b/ballerina/tests/tests.bal index 854f054..62204a7 100644 --- a/ballerina/tests/tests.bal +++ b/ballerina/tests/tests.bal @@ -74,7 +74,7 @@ import ballerina/test; [string, string][] pluralDatasetExceptions = [ ["box", "boxes"], ["Octopus", "Octopuses"], - ["KNIFE", "KNIVES"], + ["KNIfe", "KNIves"], ["loaf", "loaves"], ["index", "indices"], ["sheep", "sheep"], diff --git a/changelog.md b/changelog.md index ccf9e65..f7676a7 100644 --- a/changelog.md +++ b/changelog.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added ### Changed +- Disable restore case functionality by default. ## [1.0.0] - 03/06/2024