Fix bugs in jst relative paths and unknown filetypes
authorNick Downing <downing.nick@gmail.com>
Sun, 21 Oct 2018 05:18:43 +0000 (16:18 +1100)
committerNick Downing <downing.nick@gmail.com>
Sun, 21 Oct 2018 05:18:43 +0000 (16:18 +1100)
Site.js
config/mime_types.json

diff --git a/Site.js b/Site.js
index 0edc74f..1ca91b0 100644 (file)
--- a/Site.js
+++ b/Site.js
@@ -185,7 +185,7 @@ Site.prototype.flush_json = async function(path) {
 Site.prototype.serve_jst = async function(env, pathname) {
   let jst
   try {
-    jst = await js_template(this.root, this.root, this.root + pathname)
+    jst = await js_template(this.root, this.root, pathname)
   }
   catch (err) {
     if (err.code !== 'ENOENT')
@@ -346,14 +346,16 @@ Site.prototype.respond = async function(env) {
       if (err.code !== 'ENOENT')
         throw err
       console.log(
-        `${env.parsed_url.host} directory not found: ${pathname}`
+        `${env.parsed_url.host} directory not found ${pathname}`
       )
       this.server.die(env.response)
       return
     }
     if (!stats.isDirectory()) {
       console.log(
-        `${env.parsed_url.host} not directory: ${pathname}`
+        j < env.pathname.length ?
+        `${env.parsed_url.host} not directory ${pathname}` :
+        `${env.parsed_url.host} unknown filetype "${filetype}" in ${pathname}`
       )
       this.server.die(env.response)
       return
index 6a6a4e3..6746747 100644 (file)
@@ -7,5 +7,6 @@
   ".js": "application/javascript; charset=utf-8",
   ".json": "application/json; charset=utf-8",
   ".png": "image/png",
+  ".svg": "image/svg+xml",
   ".xml": "text/xml; charset=utf-8"
 }