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.js CHANGED
@@ -4833,9 +4833,17 @@ var createRouter = (endpoints, config) => {
4833
4833
  }
4834
4834
  const processRequest = async (request) => {
4835
4835
  const url = new URL(request.url);
4836
- const path = config?.basePath ? url.pathname.split(config.basePath)[1] : url.pathname;
4836
+ const path = config?.basePath ? url.pathname.split(config.basePath).reduce((acc, curr, index) => {
4837
+ if (index !== 0) {
4838
+ if (index > 1) {
4839
+ acc.push(`${config.basePath}${curr}`);
4840
+ } else {
4841
+ acc.push(curr);
4842
+ }
4843
+ }
4844
+ return acc;
4845
+ }, []).join("") : url.pathname;
4837
4846
  if (!path?.length) {
4838
- config?.onError?.(new Error("NOT_FOUND"));
4839
4847
  return new Response(null, { status: 404, statusText: "Not Found" });
4840
4848
  }
4841
4849
  const route = findRoute(router, request.method, path);