This commit is contained in:
2026-08-14 16:03:47 +01:00
parent fd53e3f4fb
commit dfdc3b2840
2463 changed files with 186456 additions and 111315 deletions
+9 -5
View File
@@ -1,4 +1,3 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -140,7 +139,7 @@ class Hono {
handler = async (c, next) => (await (0, import_compose.compose)([], app.errorHandler)(c, () => r.handler(c, next))).res;
handler[import_constants.COMPOSED_HANDLER] = r.handler;
}
subApp.#addRoute(r.method, r.path, handler);
subApp.#addRoute(r.method, r.path, handler, r.basePath);
});
return this;
}
@@ -264,7 +263,7 @@ class Hono {
const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
return (request) => {
const url = new URL(request.url);
url.pathname = url.pathname.slice(pathPrefixLength) || "/";
url.pathname = this.getPath(request).slice(pathPrefixLength) || "/";
return new Request(url, request);
};
})();
@@ -278,10 +277,15 @@ class Hono {
this.#addRoute(import_router.METHOD_NAME_ALL, (0, import_url.mergePath)(path, "*"), handler);
return this;
}
#addRoute(method, path, handler) {
#addRoute(method, path, handler, baseRoutePath) {
method = method.toUpperCase();
path = (0, import_url.mergePath)(this._basePath, path);
const r = { basePath: this._basePath, path, method, handler };
const r = {
basePath: baseRoutePath !== void 0 ? (0, import_url.mergePath)(this._basePath, baseRoutePath) : this._basePath,
path,
method,
handler
};
this.router.add(method, path, [handler, r]);
this.routes.push(r);
}