refactor: Enhance toSnakeCase method to replace multiple underscores with a single underscore

This commit is contained in:
Simon Larsen 2025-06-19 19:07:50 +01:00
parent 8b41779fa2
commit fdfabe080c
No known key found for this signature in database
GPG key ID: 96C5DCA24769DBCA

View file

@ -17,7 +17,8 @@ export class StringUtils {
.replace(/([A-Z])/g, "_$1")
.toLowerCase()
.replace(/^_/, "")
.replace(/[-\s]+/g, "_");
.replace(/[-\s]+/g, "_")
.replace(/_+/g, "_"); // Replace multiple underscores with single underscore
}
static toKebabCase(str: string): string {