From 2254ecc0267be8c19e7f1d5295886b2ba6c345c7 Mon Sep 17 00:00:00 2001
From: Milko Venkov <milko.venkov@gmail.com>
Date: Tue, 14 Nov 2023 15:14:43 +0200
Subject: [PATCH] fix: update Utils.LowerDashed function (#1171)

---
 packages/core/util/Util.ts  | 6 +++++-
 spec/acceptance/new-spec.ts | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/packages/core/util/Util.ts b/packages/core/util/Util.ts
index 9ad81cdc0..f35903f5f 100644
--- a/packages/core/util/Util.ts
+++ b/packages/core/util/Util.ts
@@ -239,7 +239,11 @@ export class Util {
 	 * lower-dashed string
 	 */
 	public static lowerDashed(text: string) {
-		return text.replace(/\s+/g, "-").toLowerCase();
+		const regex = new RegExp("[\\s]+|([\\p{Ll}](?=[\\p{Lu}\\p{Nd}]))", "gu");
+		const result = text.trim()
+				.replace(regex, "$1-")
+				.toLowerCase();
+		return result;
 	}
 
 	/**
diff --git a/spec/acceptance/new-spec.ts b/spec/acceptance/new-spec.ts
index c0a92676f..d5ada1422 100644
--- a/spec/acceptance/new-spec.ts
+++ b/spec/acceptance/new-spec.ts
@@ -29,7 +29,7 @@ describe("New command", () => {
 		expect(fs.existsSync("./jQuery Proj")).toBeTruthy();
 		expect(filesDiff("../templates/jquery/js/projects/empty/files", "./jQuery Proj")).toEqual([]);
 		const packageText = fs.readFileSync("./jQuery Proj/package.json", "utf-8");
-		expect(JSON.parse(packageText).name).toEqual("jquery-proj");
+		expect(JSON.parse(packageText).name).toEqual("j-query-proj");
 		expect(fs.existsSync("./jQuery Proj/.gitignore")).toBeTruthy();
 		testFolder = "./jQuery Proj";