summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
authorMhykol <mchaeldonald62@pm.me>2024-06-05 05:39:28 -0400
committerMhykol <mchaeldonald62@pm.me>2024-06-05 05:39:28 -0400
commit3e3d72d06049fe8c661850bce2ef536b27b663fc (patch)
treef2e72b8deaa93364e7ac0c83d90f0f3f0c020c67 /app.js
parentcd760f0cf83cb00b9c4b372ed1b6ed5baf1b6272 (diff)
Modified for user generated scripts and css
Diffstat (limited to 'app.js')
-rw-r--r--app.js29
1 files changed, 17 insertions, 12 deletions
diff --git a/app.js b/app.js
index b206cb1..433d0b1 100644
--- a/app.js
+++ b/app.js
@@ -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 {