two-stroke 8.0.25 → 8.1.0

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.
package/REVIEW.md ADDED
@@ -0,0 +1,8 @@
1
+ [//]: # Autogenerated by https://github.com/change-engine/ecu/github
2
+
3
+ # Review instructions
4
+
5
+ ## Do not report
6
+
7
+ - PRs opened by dependabot[bot]
8
+ - Any branch matching `dependabot/**`
package/oxlint.config.mjs CHANGED
@@ -54,6 +54,7 @@ export default defineConfig({
54
54
  "no-continue": "off",
55
55
  "init-declarations": "off",
56
56
  "vitest/prefer-to-be-truthy": "off",
57
+ "vitest/prefer-to-be-falsy": "off",
57
58
  "vitest/prefer-expect-assertions": "off",
58
59
  "vitest/prefer-importing-vitest-globals": "off",
59
60
  "vitest/no-importing-vitest-globals": "error",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "two-stroke",
3
- "version": "8.0.25",
3
+ "version": "8.1.0",
4
4
  "description": "Simple Cloudflare Worker framework.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -30,9 +30,9 @@
30
30
  "zod": "^4.4.3"
31
31
  },
32
32
  "devDependencies": {
33
- "@cloudflare/vitest-pool-workers": "^0.21.0",
33
+ "@cloudflare/vitest-pool-workers": "^0.22.0",
34
34
  "knip": "^6.31.0",
35
- "oxfmt": "^0.63.0",
35
+ "oxfmt": "^0.65.0",
36
36
  "oxlint": "^1.76.0",
37
37
  "oxlint-tsgolint": "^7.0.2001",
38
38
  "vitest": "^4.1.10"
package/src/index.ts CHANGED
@@ -72,9 +72,12 @@ export function twoStroke<T>(
72
72
  });
73
73
  }
74
74
  const { pathname } = new URL(req.url);
75
+ // HEAD is served by the GET route, with the body discarded.
76
+ const isHead = req.method === "HEAD";
77
+ const method = isHead ? "GET" : req.method;
75
78
  let response;
76
79
  for (const route of routes) {
77
- if (req.method === route.method && route.matcher.test(pathname)) {
80
+ if (method === route.method && route.matcher.test(pathname)) {
78
81
  const params = Object.fromEntries(
79
82
  Object.entries(pathname.match(route.matcher)?.groups ?? {}).map(([k, v]) => [
80
83
  k,
@@ -199,9 +202,11 @@ export function twoStroke<T>(
199
202
  });
200
203
 
201
204
  return new Response(
202
- responseWithHeaders.headers.get("Content-Type") === "application/json"
203
- ? JSON.stringify(response.body)
204
- : response.body,
205
+ isHead
206
+ ? null
207
+ : responseWithHeaders.headers.get("Content-Type") === "application/json"
208
+ ? JSON.stringify(response.body)
209
+ : response.body,
205
210
  responseWithHeaders,
206
211
  );
207
212
  }