@stacksjs/bun-router 0.1.5 → 0.1.7

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.
@@ -335,4 +335,17 @@ export declare const RequestHelpers: {
335
335
  */
336
336
  parseCookies: (cookieHeader: string) => Record<string, string>;
337
337
  };
338
+ /**
339
+ * `request.query`, built once per request.
340
+ *
341
+ * `EnhancedRequest` declares `query` as a non-optional
342
+ * `Record<string, string | string[]>`, and on the server path nothing ever
343
+ * assigned it - so `req.query.a` type-checked and then threw
344
+ * `undefined is not an object`. A declared property that does not exist is the
345
+ * worst version of a type-versus-runtime gap: not a wrong value, a 500.
346
+ *
347
+ * A repeated key (`?a=1&a=2`) becomes an array, which is what the declared type
348
+ * has always promised.
349
+ */
350
+ export declare function getParsedQuery(req: EnhancedRequest): Record<string, string | string[]>;
338
351
  export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Path params, decoded — once.
3
+ *
4
+ * The matchers took the raw path segment, so `/f/{name}` given
5
+ * `/f/caf%C3%A9` handed the handler the literal `caf%C3%A9`, and a space
6
+ * arrived as `%20`. Every consumer had to decode, which means every consumer
7
+ * that forgot had a bug, and the one framework that remembered
8
+ * (`@stacksjs/router`) had to do it in a wrapper.
9
+ *
10
+ * Doing it here rather than in a wrapper is what makes it exactly once. Two
11
+ * layers each calling `decodeURIComponent` turn `%2520` into a space, and a
12
+ * double decode is how a filter that rejects `../` gets walked past.
13
+ *
14
+ * Note for handlers: a decoded param CAN contain `/` (from `%2F`) — that is
15
+ * the point of encoding it — so anything joining a param into a filesystem
16
+ * path still has to sanitise. Decoding makes the value correct, not safe.
17
+ */
18
+ export declare function decodeParam(value: string): string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/bun-router",
3
3
  "type": "module",
4
- "version": "0.1.5",
4
+ "version": "0.1.7",
5
5
  "description": "A fast, type-safe router for Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",