Created
June 25, 2024 13:42
-
-
Save TheDevMinerTV/094eb1259fe3bb23564f24fb51d0a134 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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