File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export const kebabCase = (str: string) => str.replace(/([a-z0-9])([A-Z])/g, '$1-
2020 * @param str - The string to convert
2121 * @returns String in PascalCase format
2222 */
23- export const pascalCase = ( str : string ) => str . replace ( / ( ^ \w | - \w ) / g, char => char . replace ( '-' , '' ) . toUpperCase ( ) ) ;
23+ export const pascalCase = ( str : string ) => str . replace ( / ( ^ \w | [ - _ ] \w ) / g, char => char . replace ( / [ - _ ] / , '' ) . toUpperCase ( ) ) ;
2424
2525/**
2626 * Convert string to camelCase format (驼峰命名)
@@ -32,7 +32,7 @@ export const pascalCase = (str: string) => str.replace(/(^\w|-\w)/g, char => cha
3232 * @param str - The string to convert
3333 * @returns String in camelCase format
3434 */
35- export const camelCase = ( str : string ) => str . replace ( / ( - \w ) / g, char => char . replace ( '-' , '' ) . toUpperCase ( ) ) ;
35+ export const camelCase = ( str : string ) => str . replace ( / ( [ - _ ] \w ) / g, char => char . replace ( / [ - _ ] / , '' ) . toUpperCase ( ) ) ;
3636
3737/**
3838 * Convert string to snake_case format (蛇形命名)
You can’t perform that action at this time.
0 commit comments