summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
authorMhykol <mchaeldonald62@pm.me>2024-05-16 02:46:23 -0400
committerMhykol <mchaeldonald62@pm.me>2024-05-16 02:46:23 -0400
commit20aca1b4bba6d8dbe0b549efabcf7a01b026c63b (patch)
tree59fca4ef61d9ff3671a7e5a64f08b06496de506d /app.js
parentc23af2d13cae194be1111bbebe5233a78e972aba (diff)
Improved handling for favicon.ico and added robots.txt
Diffstat (limited to 'app.js')
-rw-r--r--app.js22
1 files changed, 16 insertions, 6 deletions
diff --git a/app.js b/app.js
index 74cb1f3..985e66a 100644
--- a/app.js
+++ b/app.js
@@ -19,6 +19,7 @@ const mime = {
png: 'image/png',
webp: 'image/webp',
avif: 'image/avif',
+ ico: 'image/ico',
svg: 'image/svg+xml',
js: 'application/javascript'
}
@@ -57,12 +58,21 @@ class App {
string: req.path
}
- if (this.path.split[1] === 'favicon.ico') {
- const data = this.readfile.GetFile('/img/favicon.ico')
- data.mime.then(output => this.#FileOpen({data: data, mime: output, res: res}))
- } else {
- 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)}
+ switch (this.path.split[1]) {
+ case 'favicon.ico':
+ this.data = this.readfile.GetFavicon()
+ this.data.mime.then(output => this.#FileOpen({data: this.data, mime: output, res: res}))
+ break
+ case 'robots.txt':
+ console.log('hit')
+ this.data = this.readfile.GetRobots()
+ this.data.mime.then(output => this.#FileOpen({data: this.data, mime: output, res: res}))
+ 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)}
+ break
+
}
})
})