Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(docs): append path separator in traversal guard

Richie McIlroyefcc58691cb5
diff --git a/apps/web/utils/docs.ts b/apps/web/utils/docs.ts
index 4eaa3e417..84b0a89e0 100644
--- a/apps/web/utils/docs.ts
+++ b/apps/web/utils/docs.ts
@@ -84,7 +84,7 @@ export const getAllDocs = cache(function getAllDocs(): Doc[] {
export function getDocBySlug(slug: string): Doc | undefined {
const filePath = path.resolve(docsDir, `${slug}.mdx`);
- if (!filePath.startsWith(docsDir)) return undefined;
+ if (!filePath.startsWith(docsDir + path.sep)) return undefined;
if (!fs.existsSync(filePath)) return undefined;
const { metadata, content } = parseFrontmatter(
fs.readFileSync(filePath, "utf-8"),