Skip to content
This repository was archived by the owner on Feb 20, 2019. It is now read-only.

Commit c103a6d

Browse files
author
Kent C. Dodds
committed
Merge pull request #10 from ajcrites/snake-case-underscore
feat(snakeToCamel): consider underscore-separated as snake_case
2 parents 5e119fc + 367ddcc commit c103a6d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/snake-to-camel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default snakeToCamel
22

3-
const regex = /(\-\w)/g
3+
const regex = /([\-_]\w)/g
44

55
/**
66
* Original Source: http://stackoverflow.com/a/6661012/971592

test/snake-to-camel.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@ test('converts snake-case to camelCase', t => {
88
t.same(actual, expected)
99
})
1010

11+
test('converts snake_case to camelCase', t => {
12+
const original = 'snake_case_string'
13+
const expected = 'snakeCaseString'
14+
const actual = snakeToCamel(original)
15+
t.same(actual, expected)
16+
})

0 commit comments

Comments
 (0)