Skip to content

Commit 7e4fd95

Browse files
docs: add migration note for UriTemplate query param handling
1 parent 6fcd8c4 commit 7e4fd95

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

docs/migration.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,26 @@ try {
759759

760760
## Enhancements
761761

762+
### `UriTemplate.match()` now handles optional query parameters
763+
764+
Resource templates with query parameters (e.g. `products{?page,limit}`) previously required all query parameters to be present in the exact order specified, or the match would fail. Now they match per RFC 6570 semantics: query parameters are optional, order-independent, and URL-decoded.
765+
766+
```typescript
767+
const template = new UriTemplate('products{?page,limit}');
768+
769+
// v1: returned null
770+
// v2: returns {}
771+
template.match('products');
772+
773+
// v1: returned null (wrong order)
774+
// v2: returns { page: '1', limit: '10' }
775+
template.match('products?limit=10&page=1');
776+
```
777+
778+
Absent query parameters are omitted from the result (not set to `''`), so you can use `vars.page ?? defaultValue`. A parameter present with an empty value (e.g. `?page=`) returns `''`, distinguishing "absent" from "empty".
779+
780+
If you were relying on strict query parameter matching to reject requests, you'll now need to validate parameters explicitly in your resource callback.
781+
762782
### Automatic JSON Schema validator selection by runtime
763783

764784
The SDK now automatically selects the appropriate JSON Schema validator based on your runtime environment:

0 commit comments

Comments
 (0)