Skip to content

Instantly share code, notes, and snippets.

@TheDevMinerTV
Created June 25, 2024 13:42
Show Gist options
  • Save TheDevMinerTV/094eb1259fe3bb23564f24fb51d0a134 to your computer and use it in GitHub Desktop.
Save TheDevMinerTV/094eb1259fe3bb23564f24fb51d0a134 to your computer and use it in GitHub Desktop.
const assert = require("assert").strict;
const pQS = require("picoquery");
const QUERY_STRING = "foo[0][bar]=baz&foo[0][fizz]=buzz&foo[]=done!";
for (const nestingSyntax of ["js", "index", "dot"]) {
for (const arrayRepeatSyntax of ["bracket", "repeat"]) {
console.log(
`\nnestingSyntax: ${nestingSyntax}, arrayRepeatSyntax: ${arrayRepeatSyntax}`
);
try {
const s = pQS.parse(QUERY_STRING, {
nesting: true,
nestingSyntax,
arrayRepeat: true,
arrayRepeatSyntax,
});
assert.deepStrictEqual(s, {
foo: [{ bar: "baz", fizz: "buzz" }, "done!"],
});
} catch (err) {
console.log(err.message);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment