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";