fix(server/utils): prepend .
to file extension checks
This commit is contained in:
parent
afcd71a50d
commit
20b69c82da
@ -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}`) },
|
||||
|
Loading…
Reference in New Issue
Block a user