Area restrita - Questionario
This commit is contained in:
+71
-41
@@ -27,7 +27,7 @@ function _interopNamespace(e) {
|
||||
var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
|
||||
|
||||
/**
|
||||
* react-router v7.14.0
|
||||
* react-router v7.17.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
@@ -61,7 +61,7 @@ function warning(cond, message) {
|
||||
function createKey() {
|
||||
return Math.random().toString(36).substring(2, 10);
|
||||
}
|
||||
function createLocation(current, to, state = null, key, unstable_mask) {
|
||||
function createLocation(current, to, state = null, key, mask) {
|
||||
let location = {
|
||||
pathname: typeof current === "string" ? current : current.pathname,
|
||||
search: "",
|
||||
@@ -73,7 +73,7 @@ function createLocation(current, to, state = null, key, unstable_mask) {
|
||||
// But that's a pretty big refactor to the current test suite so going to
|
||||
// keep as is for the time being and just let any incoming keys take precedence
|
||||
key: to && to.key || key || createKey(),
|
||||
unstable_mask
|
||||
mask
|
||||
};
|
||||
return location;
|
||||
}
|
||||
@@ -253,11 +253,11 @@ async function recurseRight(impls, info, handler, index) {
|
||||
};
|
||||
}
|
||||
function getHandlerInfo(args) {
|
||||
let { request, context, params, unstable_pattern } = args;
|
||||
let { request, context, params, pattern } = args;
|
||||
return {
|
||||
request: getReadonlyRequest(request),
|
||||
params: { ...params },
|
||||
unstable_pattern,
|
||||
pattern,
|
||||
context: getReadonlyContext(context)
|
||||
};
|
||||
}
|
||||
@@ -427,17 +427,16 @@ function mergeRouteUpdates(route, updates) {
|
||||
function matchRoutes(routes, locationArg, basename = "/") {
|
||||
return matchRoutesImpl(routes, locationArg, basename, false);
|
||||
}
|
||||
function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
|
||||
function matchRoutesImpl(routes, locationArg, basename, allowPartial, precomputedBranches) {
|
||||
let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
||||
let pathname = stripBasename(location.pathname || "/", basename);
|
||||
if (pathname == null) {
|
||||
return null;
|
||||
}
|
||||
let branches = flattenRoutes(routes);
|
||||
rankRouteBranches(branches);
|
||||
let branches = precomputedBranches ?? flattenAndRankRoutes(routes);
|
||||
let matches = null;
|
||||
let decoded = decodePath(pathname);
|
||||
for (let i = 0; matches == null && i < branches.length; ++i) {
|
||||
let decoded = decodePath(pathname);
|
||||
matches = matchRouteBranch(
|
||||
branches[i],
|
||||
decoded,
|
||||
@@ -457,6 +456,11 @@ function convertRouteMatchToUiMatch(match, loaderData) {
|
||||
handle: route.handle
|
||||
};
|
||||
}
|
||||
function flattenAndRankRoutes(routes) {
|
||||
let branches = flattenRoutes(routes);
|
||||
rankRouteBranches(branches);
|
||||
return branches;
|
||||
}
|
||||
function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
|
||||
let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
|
||||
let meta = {
|
||||
@@ -728,7 +732,7 @@ function resolvePath(to, fromPathname = "/") {
|
||||
} = typeof to === "string" ? parsePath(to) : to;
|
||||
let pathname;
|
||||
if (toPathname) {
|
||||
toPathname = toPathname.replace(/\/\/+/g, "/");
|
||||
toPathname = removeDoubleSlashes(toPathname);
|
||||
if (toPathname.startsWith("/")) {
|
||||
pathname = resolvePathname(toPathname.substring(1), "/");
|
||||
} else {
|
||||
@@ -744,7 +748,7 @@ function resolvePath(to, fromPathname = "/") {
|
||||
};
|
||||
}
|
||||
function resolvePathname(relativePath, fromPathname) {
|
||||
let segments = fromPathname.replace(/\/+$/, "").split("/");
|
||||
let segments = removeTrailingSlash(fromPathname).split("/");
|
||||
let relativeSegments = relativePath.split("/");
|
||||
relativeSegments.forEach((segment) => {
|
||||
if (segment === "..") {
|
||||
@@ -815,8 +819,10 @@ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = fal
|
||||
}
|
||||
return path;
|
||||
}
|
||||
var joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
|
||||
var normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
|
||||
var removeDoubleSlashes = (path) => path.replace(/\/\/+/g, "/");
|
||||
var joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
|
||||
var removeTrailingSlash = (path) => path.replace(/\/+$/, "");
|
||||
var normalizePathname = (pathname) => removeTrailingSlash(pathname).replace(/^\/*/, "/");
|
||||
var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
|
||||
var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
|
||||
var DataWithResponseInit = class {
|
||||
@@ -870,7 +876,8 @@ function isRouteErrorResponse(error) {
|
||||
return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
|
||||
}
|
||||
function getRoutePattern(matches) {
|
||||
return matches.map((m) => m.route.path).filter(Boolean).join("/").replace(/\/\/*/g, "/") || "/";
|
||||
let parts = matches.map((m) => m.route.path).filter(Boolean);
|
||||
return joinPaths(parts) || "/";
|
||||
}
|
||||
|
||||
// lib/router/router.ts
|
||||
@@ -903,11 +910,10 @@ function createStaticHandler(routes, opts) {
|
||||
let _mapRouteProperties = opts?.mapRouteProperties || defaultMapRouteProperties;
|
||||
let mapRouteProperties = _mapRouteProperties;
|
||||
({
|
||||
// unused in static handler
|
||||
...opts?.future
|
||||
});
|
||||
if (opts?.unstable_instrumentations) {
|
||||
let instrumentations = opts.unstable_instrumentations;
|
||||
if (opts?.instrumentations) {
|
||||
let instrumentations = opts.instrumentations;
|
||||
mapRouteProperties = (route) => {
|
||||
return {
|
||||
..._mapRouteProperties(route),
|
||||
@@ -924,6 +930,7 @@ function createStaticHandler(routes, opts) {
|
||||
void 0,
|
||||
manifest
|
||||
);
|
||||
let routeBranches = flattenAndRankRoutes(dataRoutes);
|
||||
async function query(request, {
|
||||
requestContext,
|
||||
filterMatchesToLoad,
|
||||
@@ -931,12 +938,23 @@ function createStaticHandler(routes, opts) {
|
||||
skipRevalidation,
|
||||
dataStrategy,
|
||||
generateMiddlewareResponse,
|
||||
unstable_normalizePath
|
||||
normalizePath
|
||||
} = {}) {
|
||||
let normalizePath = unstable_normalizePath || defaultNormalizePath;
|
||||
let normalizePathImpl = normalizePath || defaultNormalizePath;
|
||||
let method = request.method;
|
||||
let location = createLocation("", normalizePath(request), null, "default");
|
||||
let matches = matchRoutes(dataRoutes, location, basename);
|
||||
let location = createLocation(
|
||||
"",
|
||||
normalizePathImpl(request),
|
||||
null,
|
||||
"default"
|
||||
);
|
||||
let matches = matchRoutesImpl(
|
||||
dataRoutes,
|
||||
location,
|
||||
basename,
|
||||
false,
|
||||
routeBranches
|
||||
);
|
||||
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
||||
if (!isValidMethod(method) && method !== "HEAD") {
|
||||
let error = getInternalRouterError(405, { method });
|
||||
@@ -988,8 +1006,8 @@ function createStaticHandler(routes, opts) {
|
||||
let response = await runServerMiddlewarePipeline(
|
||||
{
|
||||
request,
|
||||
unstable_url: createDataFunctionUrl(request, location),
|
||||
unstable_pattern: getRoutePattern(matches),
|
||||
url: createDataFunctionUrl(request, location),
|
||||
pattern: getRoutePattern(matches),
|
||||
matches,
|
||||
params: matches[0].params,
|
||||
// If we're calling middleware then it must be enabled so we can cast
|
||||
@@ -1106,12 +1124,23 @@ function createStaticHandler(routes, opts) {
|
||||
requestContext,
|
||||
dataStrategy,
|
||||
generateMiddlewareResponse,
|
||||
unstable_normalizePath
|
||||
normalizePath
|
||||
} = {}) {
|
||||
let normalizePath = unstable_normalizePath || defaultNormalizePath;
|
||||
let normalizePathImpl = normalizePath || defaultNormalizePath;
|
||||
let method = request.method;
|
||||
let location = createLocation("", normalizePath(request), null, "default");
|
||||
let matches = matchRoutes(dataRoutes, location, basename);
|
||||
let location = createLocation(
|
||||
"",
|
||||
normalizePathImpl(request),
|
||||
null,
|
||||
"default"
|
||||
);
|
||||
let matches = matchRoutesImpl(
|
||||
dataRoutes,
|
||||
location,
|
||||
basename,
|
||||
false,
|
||||
routeBranches
|
||||
);
|
||||
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
||||
if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
|
||||
throw getInternalRouterError(405, { method });
|
||||
@@ -1136,8 +1165,8 @@ function createStaticHandler(routes, opts) {
|
||||
let response = await runServerMiddlewarePipeline(
|
||||
{
|
||||
request,
|
||||
unstable_url: createDataFunctionUrl(request, location),
|
||||
unstable_pattern: getRoutePattern(matches),
|
||||
url: createDataFunctionUrl(request, location),
|
||||
pattern: getRoutePattern(matches),
|
||||
matches,
|
||||
params: matches[0].params,
|
||||
// If we're calling middleware then it must be enabled so we can cast
|
||||
@@ -1521,6 +1550,7 @@ function createStaticHandler(routes, opts) {
|
||||
}
|
||||
return {
|
||||
dataRoutes,
|
||||
_internalRouteBranches: routeBranches,
|
||||
query,
|
||||
queryRoute
|
||||
};
|
||||
@@ -1872,7 +1902,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties, manifest, request,
|
||||
handler: lazyRoutePromises.lazyHandlerPromise
|
||||
};
|
||||
}
|
||||
function getDataStrategyMatch(mapRouteProperties, manifest, request, path, unstable_pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
|
||||
function getDataStrategyMatch(mapRouteProperties, manifest, request, path, pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
|
||||
let isUsingNewApi = false;
|
||||
let _lazyPromises = getDataStrategyMatchLazyPromises(
|
||||
mapRouteProperties,
|
||||
@@ -1907,7 +1937,7 @@ function getDataStrategyMatch(mapRouteProperties, manifest, request, path, unsta
|
||||
return callLoaderOrAction({
|
||||
request,
|
||||
path,
|
||||
unstable_pattern,
|
||||
pattern,
|
||||
match,
|
||||
lazyHandlerPromise: _lazyPromises?.handler,
|
||||
lazyRoutePromise: _lazyPromises?.route,
|
||||
@@ -1957,8 +1987,8 @@ async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fe
|
||||
}
|
||||
let dataStrategyArgs = {
|
||||
request,
|
||||
unstable_url: createDataFunctionUrl(request, path),
|
||||
unstable_pattern: getRoutePattern(matches),
|
||||
url: createDataFunctionUrl(request, path),
|
||||
pattern: getRoutePattern(matches),
|
||||
params: matches[0].params,
|
||||
context: scopedContext,
|
||||
matches
|
||||
@@ -1987,7 +2017,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fe
|
||||
async function callLoaderOrAction({
|
||||
request,
|
||||
path,
|
||||
unstable_pattern,
|
||||
pattern,
|
||||
match,
|
||||
lazyHandlerPromise,
|
||||
lazyRoutePromise,
|
||||
@@ -2014,8 +2044,8 @@ async function callLoaderOrAction({
|
||||
return handler(
|
||||
{
|
||||
request,
|
||||
unstable_url: createDataFunctionUrl(request, path),
|
||||
unstable_pattern,
|
||||
url: createDataFunctionUrl(request, path),
|
||||
pattern,
|
||||
params: match.params,
|
||||
context: scopedContext
|
||||
},
|
||||
@@ -2894,7 +2924,7 @@ async function generateResourceResponse(request, routes, basename, routeId, requ
|
||||
return generateErrorResponse(error);
|
||||
}
|
||||
},
|
||||
unstable_normalizePath: (r) => getNormalizedPath(r, basename, null)
|
||||
normalizePath: (r) => getNormalizedPath(r, basename, null)
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
@@ -2950,12 +2980,12 @@ async function generateRenderResponse(request, routes, basename, isDataRequest,
|
||||
skipLoaderErrorBubbling: isDataRequest,
|
||||
skipRevalidation: isSubmission,
|
||||
...routeIdsToLoad ? { filterMatchesToLoad: (m) => routeIdsToLoad.includes(m.route.id) } : {},
|
||||
unstable_normalizePath: (r) => getNormalizedPath(r, basename),
|
||||
normalizePath: (r) => getNormalizedPath(r, basename),
|
||||
async generateMiddlewareResponse(query) {
|
||||
let formState;
|
||||
let skipRevalidation = false;
|
||||
let potentialCSRFAttackError;
|
||||
if (request.method === "POST") {
|
||||
if (isMutationMethod(request.method)) {
|
||||
try {
|
||||
throwIfPotentialCSRFAttack(request.headers, allowedActionOrigins);
|
||||
ctx.runningAction = true;
|
||||
@@ -3463,7 +3493,7 @@ var unsign = async (cookie, secret) => {
|
||||
let signature = byteStringToUint8Array(atob(hash));
|
||||
let valid = await crypto.subtle.verify("HMAC", key, signature, data2);
|
||||
return valid ? value : false;
|
||||
} catch (error) {
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -3564,7 +3594,7 @@ function encodeData(value) {
|
||||
function decodeData(value) {
|
||||
try {
|
||||
return JSON.parse(decodeURIComponent(myEscape(atob(value))));
|
||||
} catch (error) {
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user