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

left.value as canonical path generates object with items not in input order?[partial code?] #52

Open
eldhoabraham94 opened this issue Jan 9, 2023 · 0 comments

Comments

@eldhoabraham94
Copy link

The following code separates the input filter value $filter=(location/address/firstname eq 'John') into an object.
The object results with the '/' sepated items in no alphabetical order, misrepresenting the original order.
Is it a partial code?

Node.prototype._prop = function (result, left, rightValue) {
if (left.type === 'property' && left.name.indexOf('/') !== -1) {
const fragments = left.name.split('/')
const obj = result[fragments[0]] || {}

for (let i = 1; i < fragments.length; i++) {
  if (i === (fragments.length - 1)) {
    obj[fragments[i]] = rightValue
  } else {
    obj[fragments[i]] = obj[fragments[i]] || {}
  }
}

result[fragments[0]] = obj

} else {
result[left.name] = rightValue
}
}

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

No branches or pull requests

1 participant