Repository navigation
-
Breaking: a key repeated in a query string or urlencoded body is now
an array (?tag=a&tag=b→{ tag: [ "a", "b" ] }), as in Express 5.
Before, the last value silently replaced the others, which lost data
from multi-select forms and filter UIs. A handler that treats
req.query.xor a form field as a string will throw if a client
repeats the key — declare the field withboxExpressValidate()or
checkisArray().- Both parsers now share
models/QueryString.bx, with the semantics of
Node'squerystring(Express 5's default "simple" parser). A key
that appears once is still a string. Brackets are not parsed:
tag[]anduser[name]stay literal keys. There is noquery parsersetting. - Keys that differ only in case are one key, because a BoxLang struct's
keys are case-insensitive:?Tag=a&tag=bis{ Tag: [ "a", "b" ] }.
Express would give two keys. - Unchanged:
+is a space in both; a malformed%escape is kept as
raw text in a query string and answered with400in a body. app.inject( { query: { tag: [ "a", "b" ] } } )already sent both
values; the handler now receives both.boxExpressUpload()does the same for a repeated non-file field
in a multipart body (models/middleware/Multipart.bx); it also kept
only the last value.boxExpressCsrf()ignores a token field sent more than once and
falls back to the header, so such a request is rejected as before.
- Both parsers now share
-
boxExpressValidate()and arrays (models/middleware/Validate.bx):type: "array"accepts a single simple value as a one-item array, so
?tag=aand?tag=a&tag=bboth validate. This also applies to
JSON bodies:"tags": "a"is now accepted as[ "a" ], where it was
a400.- An untyped field with
oneOf,pattern,minLengthor
maxLengthnow rejects an array or object ("must be a single
value"). Those rules were skipped for a non-simple value, so
{ "role": [ "root" ] }passed aoneOfcheck — and with repeated
keys,?role=root&role=xwould have too. - Scalar types already rejected arrays; that's unchanged.
-
ETags for buffered responses (
models/Response.bx,
models/ConditionalGet.bx):app.set( "etag", "weak" | "strong" | true | false | ( bodyBytes, encoding ) => tag ). Off by default —
Express turns weak tags on, but a new header and a SHA-1 pass per
response shouldn't arrive with an upgrade. An invalid value throws at
app.set(). The weak format is theetagpackage's
(W/"<length in hex>-<27 characters of base64 SHA-1>"). A response is
tagged only forGET/HEAD, a 2xx status, a non-empty body and no
ETagset by the handler. -
req.fresh/req.stale(models/Request.bx), with thefresh
package's rules as in Express 5:If-None-Match(*, a list, weak
comparison) decides when present, otherwiseIf-Modified-Since
againstLast-Modified;Cache-Control: no-cacheon the request is
always stale. They are read like properties and computed on each read. -
Buffered
GET/HEADresponses now answer304when the request is
fresh, with no body and withoutContent-TypeorContent-Length;
res.getBytesWritten()reports0. This applies withetagoff
too: a handler that already sets its ownETagorLast-Modified
beforeres.send()/res.json()will start answering matching
conditional requests with304, as Express does.sendFile(),
static files andres.sse()are unchanged.sendFile()and static files now send the file in full when the
request saysCache-Control: no-cache(a hard reload), matching
the rule above; they answered304before.- The exchange adapters gained
removeHeader(). A hand-written
exchange adapter needs one. Request.bxis now declared withaccessors=true invokeImplicitAccessor=truesoreq.freshcan be computed when
read;reqgainsgetFresh()/getStale()and unused generated
setFresh()/setStale()methods.
-
Fix:
app.inject()threw "Count cannot be zero" for a URL that is
only a query string ("?page=2") (models/BoxExpress.bx).