@bitstillery/mithril 3.7.1 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitstillery/mithril",
3
- "version": "3.7.1",
3
+ "version": "3.8.0",
4
4
  "description": "Mithril + Signals, Store and SSR",
5
5
  "license": "MIT",
6
6
  "author": "Bitstillery",
@@ -4,9 +4,14 @@ export default function buildQueryString(object: Record<string, any>): string {
4
4
  const args: string[] = []
5
5
  function destructure(key: string, value: any) {
6
6
  if (Array.isArray(value)) {
7
- for (let i = 0; i < value.length; i++) {
8
- destructure(key + '[' + i + ']', value[i])
9
- }
7
+ // A comma list, not `key[0]=&key[1]=`: it is a third of the length, it survives a CDN
8
+ // cache-key allowlist as a single parameter name, and RFC 3986 permits a bare comma in
9
+ // a query. Each element is encoded on its own, so a comma *inside* a value stays `%2C`
10
+ // and the list still splits unambiguously.
11
+ if (value.length === 0) return
12
+ args.push(
13
+ encodeURIComponent(key) + '=' + value.map((item) => (item == null ? '' : encodeURIComponent(item))).join(','),
14
+ )
10
15
  } else if (Object.prototype.toString.call(value) === '[object Object]') {
11
16
  for (const i in value) {
12
17
  destructure(key + '[' + i + ']', value[i])