Repository navigation
fix: preserve booleans when assigning query parameters - #2013
Conversation
Reviewer's GuidePreserves boolean values when query objects are stringified by allowing booleans through the existing primitive guard, while retaining string parsing, escaping, and unsupported-value behavior. Comprehensive regressions validate arrays, rewrites, and end-to-end GET/POST middleware behavior. Sequence diagram for boolean query parameter serializationsequenceDiagram
participant Client
participant Middleware
participant SearchParams as search_params
participant URLSearchParams
Client->>Middleware: GET/POST request
Middleware->>SearchParams: stringify(query)
SearchParams->>URLSearchParams: append(key, boolean)
URLSearchParams-->>SearchParams: escaped query string
SearchParams-->>Middleware: enabled=true&disabled=false
Middleware-->>Client: response with preserved query values
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2013 +/- ##
=======================================
Coverage 99.90% 99.90%
=======================================
Files 9 9
Lines 2144 2144
=======================================
Hits 2142 2142
Misses 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
yowainwright
left a comment
There was a problem hiding this comment.
Thanks for this catch!!!
Please write tests here:
- https://github.com/koajs/koa/blob/master/__tests__/lib/search-params.test.js
...Instead of the new file.
💪
There was a problem hiding this comment.
@tianrking great work! Sorry I missed your update.
I reduced the test footprint.
Thank you 🥇
|
@jonathanong @fengmk2 , I think this merged pr is a decent place to publish 3.3.0. |
Assigning
ctx.query = { enabled: true, disabled: false }currently producesenabled=&disabled=. Preserve boolean values through the existing primitive-value guard, including repeated and mixed arrays. Parsed values remain strings, escaping is unchanged, and unsupported values still serialize as empty strings.The regression tests now live in
__tests__/lib/search-params.test.js, as requested. They cover scalar and array serialization, escaping, unsupported values, query cache rewrites, and middleware behavior.Validation on the updated branch: all 469 tests pass; Standard lint and
git diff --checkpass. GitHub reports all eight checks passing.Summary by Sourcery
Preserve boolean query parameter values during serialization while retaining existing handling for other value types.
Bug Fixes:
Tests:
Summary by CodeRabbit
Bug Fixes
Tests