@statewalker/webrun-rpc-http 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.
package/README.md CHANGED
@@ -201,9 +201,9 @@ it.
201
201
  - **`baseUrl` takes no trailing slash.** The client builds
202
202
  `${baseUrl}/${service}/${method}`; a trailing slash doubles it and the call
203
203
  fails with `Not found`.
204
- - **The prefix check is a plain string prefix.** With `path: "/api/v1"`, a
205
- request to `/api/v1x/math` is also handled (here, as the descriptor). Put the
206
- handler behind a router that matches on segment boundaries if that matters.
204
+ - **The prefix matches whole path segments.** With `path: "/api/v1"`, the
205
+ handler serves `/api/v1` and everything under `/api/v1/`; `/api/v1x/math`
206
+ is outside the prefix and gets `404 Not found`.
207
207
  - **No content negotiation.** JSON or multipart in, JSON or binary out.
208
208
 
209
209
  ### Design notes
package/dist/index.js CHANGED
@@ -118,7 +118,7 @@ function buildServiceIndex(services) {
118
118
  }
119
119
  function splitRequestPath(request, prefix) {
120
120
  const pathname = new URL(request.url).pathname;
121
- if (prefix && !pathname.startsWith(prefix)) return null;
121
+ if (prefix && pathname !== prefix && !pathname.startsWith(`${prefix}/`)) return null;
122
122
  const [serviceName = "", methodName = "", ...tail] = pathname.substring(prefix.length + 1).split("/");
123
123
  return {
124
124
  serviceName: serviceName || void 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statewalker/webrun-rpc-http",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "HTTP-based service RPC: expose object methods as a (Request) => Response handler and call them with fetch",
@@ -33,7 +33,7 @@
33
33
  "src"
34
34
  ],
35
35
  "dependencies": {
36
- "@statewalker/webrun-streams": "^0.2.2"
36
+ "@statewalker/webrun-streams": "^0.2.3"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@biomejs/biome": "^2.5.15",
@@ -79,7 +79,7 @@ interface ParsedPath {
79
79
 
80
80
  function splitRequestPath(request: Request, prefix: string): ParsedPath | null {
81
81
  const pathname = new URL(request.url).pathname;
82
- if (prefix && !pathname.startsWith(prefix)) return null;
82
+ if (prefix && pathname !== prefix && !pathname.startsWith(`${prefix}/`)) return null;
83
83
  const rest = pathname.substring(prefix.length + 1);
84
84
  const [serviceName = "", methodName = "", ...tail] = rest.split("/");
85
85
  return {