From 7789ab6cb2822ca338186573c010047a3c5b0f48 Mon Sep 17 00:00:00 2001 From: whoswhip Date: Fri, 23 Jan 2026 01:33:58 -0500 Subject: [PATCH] fix: ensure JSDOM is only loaded in server-side environments --- SharpbinV3.Client/src/lib/utils/markdown.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SharpbinV3.Client/src/lib/utils/markdown.ts b/SharpbinV3.Client/src/lib/utils/markdown.ts index b1e3bea..9cc2c0f 100644 --- a/SharpbinV3.Client/src/lib/utils/markdown.ts +++ b/SharpbinV3.Client/src/lib/utils/markdown.ts @@ -15,9 +15,11 @@ export async function parseMarkdown(md: string): Promise { if (typeof window !== 'undefined') { dom = window as unknown as WindowLike & { document: Document }; - } else { + } else if (import.meta.env.SSR) { const { JSDOM } = await import('jsdom'); dom = new JSDOM('').window as unknown as WindowLike & { document: Document }; + } else { + throw new Error('JSDOM should only be loaded on the server'); } const DOMPurify = createDOMPurify(dom);