@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.js
CHANGED
|
@@ -10455,7 +10455,7 @@ function matchApiRoute(routes, pathname) {
|
|
|
10455
10455
|
if (!match) continue;
|
|
10456
10456
|
const params = {};
|
|
10457
10457
|
r.paramNames.forEach((name, idx) => {
|
|
10458
|
-
params[name] = match[idx + 1];
|
|
10458
|
+
params[name] = decodeURIComponent(match[idx + 1] || "");
|
|
10459
10459
|
});
|
|
10460
10460
|
return { route: r, params };
|
|
10461
10461
|
}
|
|
@@ -14991,6 +14991,7 @@ function getAutoRateLimiter(route, strictPatterns = [], rateLimitConfig) {
|
|
|
14991
14991
|
// modules/server/handlers/api.ts
|
|
14992
14992
|
async function handleApiRequest(options) {
|
|
14993
14993
|
const { apiRoutes, urlPath, req, res, env = "dev", rewriteLoader } = options;
|
|
14994
|
+
const originalUrlPath = urlPath;
|
|
14994
14995
|
let finalUrlPath = urlPath;
|
|
14995
14996
|
let extractedParams = {};
|
|
14996
14997
|
if (rewriteLoader) {
|
|
@@ -15029,6 +15030,33 @@ async function handleApiRequest(options) {
|
|
|
15029
15030
|
}
|
|
15030
15031
|
const sanitizedParams = sanitizeParams(params);
|
|
15031
15032
|
const sanitizedQuery = sanitizeQuery(req.query);
|
|
15033
|
+
function reconstructPathFromParams(routePattern, params2) {
|
|
15034
|
+
let reconstructed = routePattern;
|
|
15035
|
+
for (const [key, value] of Object.entries(params2)) {
|
|
15036
|
+
const catchAllPattern = `[...${key}]`;
|
|
15037
|
+
if (reconstructed.includes(catchAllPattern)) {
|
|
15038
|
+
reconstructed = reconstructed.replace(catchAllPattern, value);
|
|
15039
|
+
} else {
|
|
15040
|
+
const normalPattern = `[${key}]`;
|
|
15041
|
+
if (reconstructed.includes(normalPattern)) {
|
|
15042
|
+
reconstructed = reconstructed.replace(normalPattern, value);
|
|
15043
|
+
}
|
|
15044
|
+
}
|
|
15045
|
+
}
|
|
15046
|
+
return reconstructed;
|
|
15047
|
+
}
|
|
15048
|
+
const reconstructedPath = reconstructPathFromParams(route.pattern, sanitizedParams);
|
|
15049
|
+
const queryString = req.url?.includes("?") ? req.url.split("?")[1] : "";
|
|
15050
|
+
const originalUrl = queryString ? `${reconstructedPath}?${queryString}` : reconstructedPath;
|
|
15051
|
+
if (!req.originalUrl) {
|
|
15052
|
+
req.originalUrl = originalUrl;
|
|
15053
|
+
}
|
|
15054
|
+
if (!req.params) {
|
|
15055
|
+
req.params = {};
|
|
15056
|
+
}
|
|
15057
|
+
for (const [key, value] of Object.entries(sanitizedParams)) {
|
|
15058
|
+
req.params[key] = value;
|
|
15059
|
+
}
|
|
15032
15060
|
const ctx = {
|
|
15033
15061
|
req,
|
|
15034
15062
|
res,
|