@koa/router 15.1.0 → 15.1.1

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/dist/index.d.mts CHANGED
@@ -816,7 +816,7 @@ type RouterContext<StateT = DefaultState, ContextT = DefaultContext, BodyT = unk
816
816
  /**
817
817
  * Router middleware function type
818
818
  */
819
- type RouterMiddleware<StateT = DefaultState, ContextT = DefaultContext, BodyT = unknown> = (context: RouterContext<StateT, ContextT, BodyT>, next: () => Promise<unknown>) => unknown | Promise<unknown>;
819
+ type RouterMiddleware<StateT = DefaultState, ContextT = DefaultContext, BodyT = unknown> = Middleware<StateT, RouterContext<StateT, ContextT, BodyT>, BodyT>;
820
820
  /**
821
821
  * HTTP method names in lowercase
822
822
  */
package/dist/index.d.ts CHANGED
@@ -816,7 +816,7 @@ type RouterContext<StateT = DefaultState, ContextT = DefaultContext, BodyT = unk
816
816
  /**
817
817
  * Router middleware function type
818
818
  */
819
- type RouterMiddleware<StateT = DefaultState, ContextT = DefaultContext, BodyT = unknown> = (context: RouterContext<StateT, ContextT, BodyT>, next: () => Promise<unknown>) => unknown | Promise<unknown>;
819
+ type RouterMiddleware<StateT = DefaultState, ContextT = DefaultContext, BodyT = unknown> = Middleware<StateT, RouterContext<StateT, ContextT, BodyT>, BodyT>;
820
820
  /**
821
821
  * HTTP method names in lowercase
822
822
  */
package/dist/index.js CHANGED
@@ -850,16 +850,10 @@ var Router = class {
850
850
  const previousPrefix = this.opts.prefix || "";
851
851
  this.opts.prefix = normalizedPrefix;
852
852
  for (const route of this.stack) {
853
- if (previousPrefix && typeof route.path === "string") {
854
- if (route.path.startsWith(previousPrefix)) {
855
- route.path = route.path.slice(previousPrefix.length) || "/";
856
- route.setPrefix(normalizedPrefix);
857
- } else {
858
- route.setPrefix(normalizedPrefix);
859
- }
860
- } else {
861
- route.setPrefix(normalizedPrefix);
853
+ if (previousPrefix && typeof route.path === "string" && route.path.startsWith(previousPrefix)) {
854
+ route.path = route.path.slice(previousPrefix.length) || "/";
862
855
  }
856
+ route.setPrefix(normalizedPrefix);
863
857
  }
864
858
  return this;
865
859
  }
package/dist/index.mjs CHANGED
@@ -813,16 +813,10 @@ var Router = class {
813
813
  const previousPrefix = this.opts.prefix || "";
814
814
  this.opts.prefix = normalizedPrefix;
815
815
  for (const route of this.stack) {
816
- if (previousPrefix && typeof route.path === "string") {
817
- if (route.path.startsWith(previousPrefix)) {
818
- route.path = route.path.slice(previousPrefix.length) || "/";
819
- route.setPrefix(normalizedPrefix);
820
- } else {
821
- route.setPrefix(normalizedPrefix);
822
- }
823
- } else {
824
- route.setPrefix(normalizedPrefix);
816
+ if (previousPrefix && typeof route.path === "string" && route.path.startsWith(previousPrefix)) {
817
+ route.path = route.path.slice(previousPrefix.length) || "/";
825
818
  }
819
+ route.setPrefix(normalizedPrefix);
826
820
  }
827
821
  return this;
828
822
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@koa/router",
3
3
  "description": "Router middleware for koa. Maintained by Forward Email and Lad.",
4
- "version": "15.1.0",
4
+ "version": "15.1.1",
5
5
  "author": "Alex Mingoia <talk@alexmingoia.com>",
6
6
  "bugs": {
7
7
  "url": "https://github.com/koajs/router/issues",
@@ -41,13 +41,13 @@
41
41
  "@types/debug": "^4.1.12",
42
42
  "@types/jsonwebtoken": "^9.0.7",
43
43
  "@types/koa": "^3.0.1",
44
- "@types/node": "^25.0.1",
44
+ "@types/node": "^25.0.3",
45
45
  "@types/supertest": "^6.0.3",
46
- "@typescript-eslint/eslint-plugin": "^8.49.0",
47
- "@typescript-eslint/parser": "^8.49.0",
46
+ "@typescript-eslint/eslint-plugin": "^8.50.0",
47
+ "@typescript-eslint/parser": "^8.50.0",
48
48
  "c8": "^10.1.3",
49
49
  "chalk": "^5.4.1",
50
- "eslint": "^9.39.1",
50
+ "eslint": "^9.39.2",
51
51
  "eslint-plugin-unicorn": "^62.0.0",
52
52
  "husky": "^9.1.7",
53
53
  "joi": "^18.0.2",