Skip to content

Commit

Permalink
Add console messages for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
NebraskaCoder committed Feb 23, 2024
1 parent 6dface2 commit 2f267fd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/aboutPages.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import fs from "fs";
import path from "path";

Expand All @@ -7,12 +8,15 @@ import { processMarkdownAsHTML } from "@/utils/remarkUtils";
const contentDirectory = path.join(process.cwd(), "app/[locale]/about/[slug]");

export async function checkIfSlugIsValid(slug: string) {
console.info("checking slug", slug);
if (!slug || typeof slug !== "string") {
console.error("slug is not a string", slug);
return false;
}

// Check that the slug does not contain any slashes to prevent directory traversal
if (slug.includes("/") || slug.includes("\\")) {
console.error("slug contains slashes", slug);
return false;
}

Expand All @@ -21,7 +25,8 @@ export async function checkIfSlugIsValid(slug: string) {
try {
await fs.promises.access(fullPath);
return true;
} catch {
} catch (e) {
console.error("slug error", slug);
return false;
}
}
Expand Down

0 comments on commit 2f267fd

Please sign in to comment.