import type { BrowserRouteContext, ProfileContext } from "../server-context.js"; import type { BrowserRequest, BrowserResponse, BrowserRouteHandler } from "./types.js";
/** *Extractprofilenamefromquerystringorbodyandgetprofilecontext. *QuerystringtakesprecedenceoverbodyforconsistencywithGETroutes.
*/
export function getProfileContext(
req: BrowserRequest,
ctx: BrowserRouteContext,
): ProfileContext | { error: string; status: number } {
let profileName: string | undefined;
// Check query string first (works for GET and POST) if (typeof req.query.profile === "string") {
profileName = normalizeOptionalString(req.query.profile);
}
// Fall back to body for POST requests if (!profileName && req.body && typeof req.body === "object") { const body = req.body as Record<string, unknown>; if (typeof body.profile === "string") {
profileName = normalizeOptionalString(body.profile);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.