mirror of
https://github.com/TriliumNext/Trilium.git
synced 2025-12-11 14:01:38 -06:00
refactor(server): add validation for HTML/Markdown rendering
This commit is contained in:
parent
f1ee79e75a
commit
1ed46bd47c
@ -31,6 +31,9 @@ function getIconUsage() {
|
|||||||
|
|
||||||
function renderMarkdown(req: Request) {
|
function renderMarkdown(req: Request) {
|
||||||
const { markdownContent } = req.body;
|
const { markdownContent } = req.body;
|
||||||
|
if (!markdownContent || typeof markdownContent !== 'string') {
|
||||||
|
throw new Error('markdownContent parameter is required and must be a string');
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
htmlContent: markdownService.renderToHtml(markdownContent, "")
|
htmlContent: markdownService.renderToHtml(markdownContent, "")
|
||||||
} satisfies RenderMarkdownResponse;
|
} satisfies RenderMarkdownResponse;
|
||||||
@ -38,6 +41,9 @@ function renderMarkdown(req: Request) {
|
|||||||
|
|
||||||
function toMarkdown(req: Request) {
|
function toMarkdown(req: Request) {
|
||||||
const { htmlContent } = req.body;
|
const { htmlContent } = req.body;
|
||||||
|
if (!htmlContent || typeof htmlContent !== 'string') {
|
||||||
|
throw new Error('htmlContent parameter is required and must be a string');
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
markdownContent: markdown.toMarkdown(htmlContent)
|
markdownContent: markdown.toMarkdown(htmlContent)
|
||||||
} satisfies ToMarkdownResponse;
|
} satisfies ToMarkdownResponse;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user