fix(utils/camelToSnakeCase): better number handling
This commit is contained in:
parent
27a2853ee8
commit
5d0b40f752
@ -60,7 +60,7 @@ export const streamToBuffer = getStream.buffer
|
||||
|
||||
export function camelToSnakeCase (string) {
|
||||
return string.replace(
|
||||
/([a-z])([A-Z])/g,
|
||||
/([a-z0-9])([A-Z])/g,
|
||||
(_, prevChar, currChar) => `${prevChar}_${currChar.toLowerCase()}`
|
||||
)
|
||||
}
|
||||
|
@ -20,10 +20,12 @@ import {
|
||||
describe('camelToSnakeCase()', function () {
|
||||
it('converts a string from camelCase to snake_case', function () {
|
||||
expect(camelToSnakeCase('fooBar')).to.equal('foo_bar')
|
||||
expect(camelToSnakeCase('ipv4Allowed')).to.equal('ipv4_allowed')
|
||||
})
|
||||
|
||||
it('does not alter snake_case strings', function () {
|
||||
expect(camelToSnakeCase('foo_bar')).to.equal('foo_bar')
|
||||
expect(camelToSnakeCase('ipv4_allowed')).to.equal('ipv4_allowed')
|
||||
})
|
||||
|
||||
it('does not alter upper case letters expect those from the camelCase', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user