Lazyloaded jsdom dependency

- we can move this later into the code to prevent it from being eagerly
  loaded and taking up CPU time and memory
This commit is contained in:
Daniel Lockyer 2024-10-15 11:18:53 +02:00 committed by Daniel Lockyer
parent 1c9e55cf7b
commit 8fd32f012b

View File

@ -6,7 +6,6 @@ const errors = require('@tryghost/errors');
const config = require('../../../../shared/config'); const config = require('../../../../shared/config');
const tpl = require('@tryghost/tpl'); const tpl = require('@tryghost/tpl');
const logging = require('@tryghost/logging'); const logging = require('@tryghost/logging');
const {JSDOM} = require('jsdom');
const messages = { const messages = {
db: { db: {
@ -160,6 +159,8 @@ const checkFileIsValid = (fileData, types, extensions) => {
* *
*/ */
const isSvgSafe = (filepath) => { const isSvgSafe = (filepath) => {
const {JSDOM} = require('jsdom');
const fileContent = fs.readFileSync(filepath, 'utf8'); const fileContent = fs.readFileSync(filepath, 'utf8');
const document = new JSDOM(fileContent).window.document; const document = new JSDOM(fileContent).window.document;
document.body.innerHTML = fileContent; document.body.innerHTML = fileContent;