@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/cli.js
CHANGED
|
@@ -10414,7 +10414,7 @@ function matchApiRoute(routes, pathname) {
|
|
|
10414
10414
|
if (!match) continue;
|
|
10415
10415
|
const params = {};
|
|
10416
10416
|
r.paramNames.forEach((name, idx) => {
|
|
10417
|
-
params[name] = match[idx + 1];
|
|
10417
|
+
params[name] = decodeURIComponent(match[idx + 1] || "");
|
|
10418
10418
|
});
|
|
10419
10419
|
return { route: r, params };
|
|
10420
10420
|
}
|
|
@@ -17112,6 +17112,7 @@ function getAutoRateLimiter(route, strictPatterns = [], rateLimitConfig) {
|
|
|
17112
17112
|
// modules/server/handlers/api.ts
|
|
17113
17113
|
async function handleApiRequest(options) {
|
|
17114
17114
|
const { apiRoutes, urlPath, req, res, env = "dev", rewriteLoader } = options;
|
|
17115
|
+
const originalUrlPath = urlPath;
|
|
17115
17116
|
let finalUrlPath = urlPath;
|
|
17116
17117
|
let extractedParams = {};
|
|
17117
17118
|
if (rewriteLoader) {
|
|
@@ -17150,6 +17151,33 @@ async function handleApiRequest(options) {
|
|
|
17150
17151
|
}
|
|
17151
17152
|
const sanitizedParams = sanitizeParams(params);
|
|
17152
17153
|
const sanitizedQuery = sanitizeQuery(req.query);
|
|
17154
|
+
function reconstructPathFromParams(routePattern, params2) {
|
|
17155
|
+
let reconstructed = routePattern;
|
|
17156
|
+
for (const [key, value] of Object.entries(params2)) {
|
|
17157
|
+
const catchAllPattern = `[...${key}]`;
|
|
17158
|
+
if (reconstructed.includes(catchAllPattern)) {
|
|
17159
|
+
reconstructed = reconstructed.replace(catchAllPattern, value);
|
|
17160
|
+
} else {
|
|
17161
|
+
const normalPattern = `[${key}]`;
|
|
17162
|
+
if (reconstructed.includes(normalPattern)) {
|
|
17163
|
+
reconstructed = reconstructed.replace(normalPattern, value);
|
|
17164
|
+
}
|
|
17165
|
+
}
|
|
17166
|
+
}
|
|
17167
|
+
return reconstructed;
|
|
17168
|
+
}
|
|
17169
|
+
const reconstructedPath = reconstructPathFromParams(route.pattern, sanitizedParams);
|
|
17170
|
+
const queryString = req.url?.includes("?") ? req.url.split("?")[1] : "";
|
|
17171
|
+
const originalUrl = queryString ? `${reconstructedPath}?${queryString}` : reconstructedPath;
|
|
17172
|
+
if (!req.originalUrl) {
|
|
17173
|
+
req.originalUrl = originalUrl;
|
|
17174
|
+
}
|
|
17175
|
+
if (!req.params) {
|
|
17176
|
+
req.params = {};
|
|
17177
|
+
}
|
|
17178
|
+
for (const [key, value] of Object.entries(sanitizedParams)) {
|
|
17179
|
+
req.params[key] = value;
|
|
17180
|
+
}
|
|
17153
17181
|
const ctx = {
|
|
17154
17182
|
req,
|
|
17155
17183
|
res,
|