better-call 1.0.10 → 1.0.12
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.cjs +10 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4871,9 +4871,17 @@ var createRouter = (endpoints, config) => {
|
|
|
4871
4871
|
}
|
|
4872
4872
|
const processRequest = async (request) => {
|
|
4873
4873
|
const url = new URL(request.url);
|
|
4874
|
-
const path = config?.basePath ? url.pathname.split(config.basePath)
|
|
4874
|
+
const path = config?.basePath ? url.pathname.split(config.basePath).reduce((acc, curr, index) => {
|
|
4875
|
+
if (index !== 0) {
|
|
4876
|
+
if (index > 1) {
|
|
4877
|
+
acc.push(`${config.basePath}${curr}`);
|
|
4878
|
+
} else {
|
|
4879
|
+
acc.push(curr);
|
|
4880
|
+
}
|
|
4881
|
+
}
|
|
4882
|
+
return acc;
|
|
4883
|
+
}, []).join("") : url.pathname;
|
|
4875
4884
|
if (!path?.length) {
|
|
4876
|
-
config?.onError?.(new Error("NOT_FOUND"));
|
|
4877
4885
|
return new Response(null, { status: 404, statusText: "Not Found" });
|
|
4878
4886
|
}
|
|
4879
4887
|
const route = (0, import_rou3.findRoute)(router, request.method, path);
|