release: WRNexusJS 0.8.3
This commit is contained in:
@@ -1279,11 +1279,14 @@ export function createHandlers(deps: RuntimeDeps): Handlers {
|
||||
|
||||
async function handleClientLoad(ctx: Context): Promise<Response> {
|
||||
const routePath = ctx.url.searchParams.get("route") ?? "";
|
||||
const routeSearch = ctx.url.searchParams.get("search") ?? "";
|
||||
const name = ctx.url.searchParams.get("name") ?? "";
|
||||
if (
|
||||
!routePath.startsWith("/") ||
|
||||
routePath.startsWith("/__wrnexus/") ||
|
||||
!isSafeRequestPath(routePath) ||
|
||||
(routeSearch !== "" &&
|
||||
(!routeSearch.startsWith("?") || routeSearch.includes("#") || routeSearch.length > 4096)) ||
|
||||
!/^[A-Za-z_$][\w$]{0,63}$/.test(name)
|
||||
) {
|
||||
return new Response("Not Found", { status: 404 });
|
||||
@@ -1294,8 +1297,11 @@ export function createHandlers(deps: RuntimeDeps): Handlers {
|
||||
const load = pageModule.__wrnexusClientLoad;
|
||||
if (typeof load !== "function") return new Response("Not Found", { status: 404 });
|
||||
try {
|
||||
ctx.params = page.params;
|
||||
const values = await load(ctx);
|
||||
const routeUrl = new URL(routePath + routeSearch, ctx.url.origin);
|
||||
if (routeUrl.pathname !== routePath) return new Response("Not Found", { status: 404 });
|
||||
const routeRequest = new Request(routeUrl, { method: "GET", headers: ctx.req.headers });
|
||||
const loadCtx: Context = { ...ctx, req: routeRequest, url: routeUrl, params: page.params };
|
||||
const values = await load(loadCtx);
|
||||
if (!values || typeof values !== "object" || !(name in values)) {
|
||||
return new Response("Not Found", { status: 404 });
|
||||
}
|
||||
@@ -1627,6 +1633,10 @@ export function createHandlers(deps: RuntimeDeps): Handlers {
|
||||
if (partial) {
|
||||
body = typeof precomputedShell === "string" ? precomputedShell : (pagePartial?.shell ?? body);
|
||||
}
|
||||
const routeParamsMarker = `<span hidden data-wrn-route-params="${escapeHtml(
|
||||
JSON.stringify(ctx.params ?? {}),
|
||||
)}"></span>`;
|
||||
body = `${routeParamsMarker}${body}`;
|
||||
if (body.includes("data-wrn-action=")) {
|
||||
body = body.replace(
|
||||
/(<form\b[^>]*\bdata-wrn-action=(?:"[^"]+"|'[^']+')[^>]*>)/gi,
|
||||
|
||||
Reference in New Issue
Block a user