Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug when {. $== $var} will return substitutions item length -1 items. #59

Closed
xpol opened this issue Mar 10, 2017 · 1 comment · Fixed by #60
Closed

Bug when {. $== $var} will return substitutions item length -1 items. #59

xpol opened this issue Mar 10, 2017 · 1 comment · Fixed by #60

Comments

@xpol
Copy link
Contributor

xpol commented Mar 10, 2017

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 in array have length 3 will also returned that is "big", "pig"
  • When ext is ['.m4a', 'jpg'] the length are 4 and 3, so all items in array have length 3 and 2 will also returned that is "hi", "ho", "xi", "big", "pig"

Tested with jspath 0.3.3.

xpol added a commit to xpol/jspath that referenced this issue Mar 10, 2017
@dfilatov
Copy link
Owner

fixed in 0.3.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants