From 04bfbdb6e89df6d7959f8863186da909bccfb324 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Wed, 2 Oct 2024 20:25:14 +0200 Subject: [PATCH] clean up --- .../generate-umbraco-alias.function.ts | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/utils/string/generate-umbraco-alias/generate-umbraco-alias.function.ts b/src/Umbraco.Web.UI.Client/src/packages/core/utils/string/generate-umbraco-alias/generate-umbraco-alias.function.ts index a0056c9df2..0e4024ef1e 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/utils/string/generate-umbraco-alias/generate-umbraco-alias.function.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/utils/string/generate-umbraco-alias/generate-umbraco-alias.function.ts @@ -1,18 +1,10 @@ import { toCamelCase } from '../to-camel-case/index.js'; /** - * - * @param text + * @description Generate an alias from a string + * @param {string} text The text to generate the alias from + * @returns {string} The alias */ -export function generateAlias(text: string) { - //replace all spaces characters with a dash and remove all non-alphanumeric characters, except underscore. Allow a maximum of 1 dashes or underscores in a row. - //Do we really want that and not the original way of doing things (camelCase)? - +export function generateAlias(text: string): string { return toCamelCase(text); - - return text - .replace(/\s+/g, '-') - .replace(/[^a-zA-Z0-9_-]+/g, '') - .replace(/[-_]{2,}/g, (match) => match[0]) - .toLowerCase(); }