@lolyjs/core 0.2.0-alpha.33 → 0.2.0-alpha.34
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/cli.cjs +29 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +29 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +29 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -10490,7 +10490,7 @@ function matchApiRoute(routes, pathname) {
|
|
|
10490
10490
|
if (!match) continue;
|
|
10491
10491
|
const params = {};
|
|
10492
10492
|
r.paramNames.forEach((name, idx) => {
|
|
10493
|
-
params[name] = match[idx + 1];
|
|
10493
|
+
params[name] = decodeURIComponent(match[idx + 1] || "");
|
|
10494
10494
|
});
|
|
10495
10495
|
return { route: r, params };
|
|
10496
10496
|
}
|
|
@@ -15026,6 +15026,7 @@ function getAutoRateLimiter(route, strictPatterns = [], rateLimitConfig) {
|
|
|
15026
15026
|
// modules/server/handlers/api.ts
|
|
15027
15027
|
async function handleApiRequest(options) {
|
|
15028
15028
|
const { apiRoutes, urlPath, req, res, env = "dev", rewriteLoader } = options;
|
|
15029
|
+
const originalUrlPath = urlPath;
|
|
15029
15030
|
let finalUrlPath = urlPath;
|
|
15030
15031
|
let extractedParams = {};
|
|
15031
15032
|
if (rewriteLoader) {
|
|
@@ -15064,6 +15065,33 @@ async function handleApiRequest(options) {
|
|
|
15064
15065
|
}
|
|
15065
15066
|
const sanitizedParams = sanitizeParams(params);
|
|
15066
15067
|
const sanitizedQuery = sanitizeQuery(req.query);
|
|
15068
|
+
function reconstructPathFromParams(routePattern, params2) {
|
|
15069
|
+
let reconstructed = routePattern;
|
|
15070
|
+
for (const [key, value] of Object.entries(params2)) {
|
|
15071
|
+
const catchAllPattern = `[...${key}]`;
|
|
15072
|
+
if (reconstructed.includes(catchAllPattern)) {
|
|
15073
|
+
reconstructed = reconstructed.replace(catchAllPattern, value);
|
|
15074
|
+
} else {
|
|
15075
|
+
const normalPattern = `[${key}]`;
|
|
15076
|
+
if (reconstructed.includes(normalPattern)) {
|
|
15077
|
+
reconstructed = reconstructed.replace(normalPattern, value);
|
|
15078
|
+
}
|
|
15079
|
+
}
|
|
15080
|
+
}
|
|
15081
|
+
return reconstructed;
|
|
15082
|
+
}
|
|
15083
|
+
const reconstructedPath = reconstructPathFromParams(route.pattern, sanitizedParams);
|
|
15084
|
+
const queryString = req.url?.includes("?") ? req.url.split("?")[1] : "";
|
|
15085
|
+
const originalUrl = queryString ? `${reconstructedPath}?${queryString}` : reconstructedPath;
|
|
15086
|
+
if (!req.originalUrl) {
|
|
15087
|
+
req.originalUrl = originalUrl;
|
|
15088
|
+
}
|
|
15089
|
+
if (!req.params) {
|
|
15090
|
+
req.params = {};
|
|
15091
|
+
}
|
|
15092
|
+
for (const [key, value] of Object.entries(sanitizedParams)) {
|
|
15093
|
+
req.params[key] = value;
|
|
15094
|
+
}
|
|
15067
15095
|
const ctx = {
|
|
15068
15096
|
req,
|
|
15069
15097
|
res,
|