From 20b69c82daf10b7bc8736c851392f7aa90fc3653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Thu, 12 Oct 2023 22:58:10 -0400 Subject: [PATCH] fix(server/utils): prepend `.` to file extension checks --- lib/server/storyHelpers/bodyHandler.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/server/storyHelpers/bodyHandler.ts b/lib/server/storyHelpers/bodyHandler.ts index b3e644a..4083afb 100644 --- a/lib/server/storyHelpers/bodyHandler.ts +++ b/lib/server/storyHelpers/bodyHandler.ts @@ -5,18 +5,20 @@ import mammoth from "mammoth"; import san from "sanitize-html"; import { sanitizeConf } from "../constants"; import { FormChapter } from "~/lib/client/types/form/story"; +import { log } from "../logger"; export default async function (bodyObj: FormChapter): Promise { let str: string = ""; + log.debug(JSON.stringify(bodyObj), { label: "bodyhandler" }); if (bodyObj.content) { str = bodyObj.content; } else if (bodyObj.file) { let ext = extname(bodyObj.file).toLowerCase(); - if (ext === "md" || ext === "markdown") + if (ext === ".md" || ext === ".markdown") str = marked.parse( readFileSync(resolve(`tmp/${bodyObj.file}`)).toString(), ); - else if (ext === "doc" || ext === "docx") + else if (ext === ".doc" || ext === ".docx") str = ( await mammoth.convertToHtml( { path: resolve(`tmp/${bodyObj.file}`) },