Bug when {. $== $var} will return substitutions item length -1 items.
Closed this issue · 1 comments
xpol commented
it('$== should work with substitutions', () => {
const array = ['a', 'b', 'C', 'hi', 'ho', 'xi', 'big', 'pig', 'ball', 'cake', 'path/to/a.m4a', 'path/to/b.jpg']
let resources = JSPath.apply('.{. $== $ext}', array, {ext: ['.m4a', '.jpg']})
expect(resources).toEqual(['path/to/a.m4a', 'path/to/b.jpg'])
// Received:
// resources: ["big", "pig", "path/to/a.m4a", "path/to/b.jpg"]
resources = JSPath.apply('.{. $== $ext}', array, {ext: ['.m4a', 'jpg']})
expect(resources).toEqual(['path/to/a.m4a', 'path/to/b.jpg'])
// Received:
// resources: ["hi", "ho", "xi", "big", "pig", "path/to/a.m4a", "path/to/b.jpg"]
})
Depends on the string length in ext
, all items with length - 1 in array
will returned.
- When ext is
['.m4a', '.jpg']
the length are all 4, so all items inarray
have length 3 will also returned that is"big", "pig"
- When ext is
['.m4a', 'jpg']
the length are 4 and 3, so all items inarray
have length 3 and 2 will also returned that is"hi", "ho", "xi", "big", "pig"
Tested with jspath 0.3.3.
dfilatov commented
fixed in 0.3.4