fix(server/utils): prepend . to file extension checks

This commit is contained in:
parent afcd71a50d
commit 20b69c82da
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

@ -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<string> {
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}`) },