Skip to content

Commit

Permalink
fix: add ability to use dashes in path names
Browse files Browse the repository at this point in the history
  • Loading branch information
ReWWeR authored and kouts committed Jul 1, 2021
1 parent dc3e967 commit e1d3432
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function isArray(arr) {
}

export function splitPath(str) {
const regex = /(\w+)|\[([^\]]+)\]/g
const regex = /([\w-]+)|\[([^\]]+)\]/g
const result = []
let path

Expand Down
7 changes: 7 additions & 0 deletions tests/unit/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ describe('splitPath', () => {
const res = splitPath(path)
expect(res).toEqual(pathArr)
})

it('returns the correct value when path has dashes in name', () => {
const path = 'foo-dash[0].baz-double-dash.qux[1]'
const pathArr = ['foo-dash', '0', 'baz-double-dash', 'qux', '1']
const res = splitPath(path)
expect(res).toEqual(pathArr)
})
})

describe('getByPath', () => {
Expand Down

0 comments on commit e1d3432

Please sign in to comment.