summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'app.js')
-rw-r--r--app.js35
1 files changed, 25 insertions, 10 deletions
diff --git a/app.js b/app.js
index 3998b0b..31609a0 100644
--- a/app.js
+++ b/app.js
@@ -81,9 +81,16 @@ class App {
break
default:
if (this.path.string.endsWith('/') && this.path.string.length > 1) this.path.string = this.path.string.substring(0, this.path.string.length - 1)
- if (output.has(this.path.string)) {res.send(this.readfile.GetMain())} else {res.sendStatus(404)}
+ if (output.has(this.path.string)) {
+ try {
+ output.get(this.path.string).then(output => res.send(this.readfile.GetMain(output.meta)))
+ } catch {
+ res.send(this.readfile.GetMain(output.get(this.path.string)))
+ }
+ } else {
+ res.sendStatus(404)
+ }
break
-
}
})
})
@@ -97,17 +104,25 @@ class App {
this.controller.Main(req.body.value).then(output => {
if (output.has(this.path.string)) {
const data = this.readfile.Create(output.get(this.path.string))
- data.then(output => {
- try {
+ try {
+ output.get(this.path.string).then(output => {
+ const object = this.readfile.Create(output.html)
const window = new JSDOM('').window
const DOMPurify = createDOMPurify(window)
- const clean = DOMPurify.sanitize(output.layouts.header + output.layouts.data + output.layouts.footer, { ADD_TAGS: ["iframe"], ADD_ATTR: ['allow', 'allowfullscreen', 'frameborder', 'scrolling'] })
+ object.then(output => {
+ 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)
+ })
+ })
+ } 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 clean = DOMPurify.sanitize(output.layouts.header + output.layouts.data + output.layouts.footer, { ADD_TAGS: ['iframe'], ADD_ATTR: ['allow', 'allowfullscreen', 'frameborder', 'scrolling'] })
res.send(clean)
- } catch (err) {
- logger.Error(err)
- res.send('Not Found')
- }
- })
+ })
+ }
} else {
res.send('Not Found')
}