formacao
This commit is contained in:
+8
@@ -51,8 +51,16 @@ var filterStaticGenerateRoutes = (hono) => {
|
||||
var isDynamicRoute = (path) => {
|
||||
return path.split("/").some((segment) => segment.startsWith(":") || segment.includes("*"));
|
||||
};
|
||||
var ensureWithinOutDir = (outDir, filePath) => {
|
||||
const normalizedOutDir = joinPaths("/", outDir);
|
||||
const normalizedFilePath = joinPaths("/", filePath);
|
||||
if (normalizedFilePath !== normalizedOutDir && !normalizedFilePath.startsWith(`${normalizedOutDir}/`)) {
|
||||
throw new Error(`Path traversal detected: "${filePath}" is outside the output directory`);
|
||||
}
|
||||
};
|
||||
export {
|
||||
dirname,
|
||||
ensureWithinOutDir,
|
||||
filterStaticGenerateRoutes,
|
||||
isDynamicRoute,
|
||||
joinPaths
|
||||
|
||||
Reference in New Issue
Block a user