Skip to content

v0.6.0

Latest

Choose a tag to compare

@nitedani nitedani released this 14 Feb 03:54
· 9 commits to main since this release

v0.6.0

Bug Fixes

Comma-separated arrays not restored from URL
When using the plain format with dynamic keys (e.g., Record<string, string[]> with initialState: { filters: {} }), comma-separated values like filters.gpus_.architecture=Blackwell,Ada were restored as the single string "Blackwell,Ada" instead of ["Blackwell", "Ada"]. The parser now splits on unescaped array separators regardless of whether a type hint exists in initialState. Escaped separators (_,) are correctly preserved.

Dynamic keys not cleared from URL
When resetting a dynamic object back to {} (e.g., clearing all filters), its URL params were not removed. The middleware now tracks which keys it wrote on the previous update, so params that disappear between state transitions are correctly cleaned up.

Breaking Changes

Plain format default arraySeparator changed from ',' to 'repeat'

The default plain format now uses repeated keys for arrays:

# Before (v0.5.0): comma-separated
?tags=a,b,c

# After (v0.6.0): repeated keys
?tags=a&tags=b&tags=c

This eliminates ambiguity between scalars and single-element arrays when using dynamic keys. With 'repeat', the number of key occurrences in the URL directly encodes whether a value is a scalar or an array — no type hint needed.

To restore the old behavior:

import { createFormat } from 'zustand-querystring/format/plain';
const format = createFormat({ arraySeparator: ',' });

Note: With arraySeparator: ',' and dynamic keys (initialState: {}), a single array value like os=CentOS is indistinguishable from a scalar string. Use 'repeat' for dynamic keys, or normalize with Array.isArray(val) ? val : [val].