create a helper function to get kebab cases of differenly cased strings

This commit is contained in:
Jacob Kim 2025-06-19 14:30:03 -07:00
parent 87decd0d83
commit 1671946668

View file

@ -25,3 +25,10 @@ export function replaceEscapedCharacters(str: string): string {
}
});
}
export function kebabOfStr(str: string): string {
return str
.replace(/([a-z])([A-Z])/g, "$1-$2") // handle camelCase and PascalCase
.replace(/[\s_]+/g, "-") // replace spaces and underscores with hyphens
.toLowerCase();
}