diff options
Diffstat (limited to 'app.js')
| -rw-r--r-- | app.js | 29 |
1 files changed, 17 insertions, 12 deletions
@@ -25,7 +25,7 @@ const mime = { mp4: 'video/mp4', webm: 'video/webm' } -const assets = [ +const assetDir = [ 'js', 'css', 'img', @@ -59,7 +59,7 @@ class App { string: req.path } - if (assets.includes(this.path.split[1])) { + if (assetDir.includes(this.path.split[1])) { const data = this.readfile.GetFile(req.path) data.mime.then(output => this.#FileOpen({data: data, mime: output, res: res})) } else { @@ -99,25 +99,30 @@ class App { if (output.has(this.path.string)) { try { output.get(this.path.string).then(output => { - const object = this.readfile.Create(output.html) - const window = new JSDOM('').window - const DOMPurify = createDOMPurify(window) - object.then(output => { + const object = { + js: output.assets.js, + css: output.assets.css + } + + this.readfile.Create(output.html).then(output => { + const DOMPurify = createDOMPurify(new JSDOM('').window) const clean = DOMPurify.sanitize(output.layouts.header + output.layouts.data + output.layouts.footer, { ADD_TAGS: ["iframe"], ADD_ATTR: ['allow', 'allowfullscreen', 'frameborder', 'scrolling'] }) - res.send(clean) + res.send(JSON.stringify({html: clean, css: object.css, js: object.js})) }) }) } catch { - const object = this.readfile.Create(output.get(this.path.string).html) - const window = new JSDOM('').window - const DOMPurify = createDOMPurify(window) - object.then(output => { + const object = { + js: output.assets.js, + css: output.assets.css + } + this.readfile.Create(output.html).then(output => { + const DOMPurify = createDOMPurify(new JSDOM('').window) const clean = DOMPurify.sanitize(output.layouts.header + output.layouts.data + output.layouts.footer, { ADD_TAGS: ['iframe'], ADD_ATTR: ['allow', 'allowfullscreen', 'frameborder', 'scrolling'] }) - res.send(clean) + res.send(JSON.stringify({html: clean, css: object.css, js: object.js})) }) } } else { |
