43081j / picoquery

A small library for parsing and serializing query strings
MIT License
70 stars 2 forks source link

Decide how to deal object keying into an array #45

Open 43081j opened 4 months ago

43081j commented 4 months ago

Currently, this is true:

const result = parse('arr[prop]=1', {
  nesting: true,
  nestingSyntax: 'js'
});

// result
({
  arr: []
});

// however, we keyed into the array and made things _weird_
result.arr.prop; // 1!

the choice to be made here is one of these two, i think:

  1. leave it as is, someone is using the syntax incorrectly (true, they should be using arr.prop=1 for an obj, and arr[0] for an array)
  2. bail when we encounter prop keys of arrays (so arr would be a regular [] with no funky properties)