Add ttf, woff and woff2 in default MIME types, fix serve_dir() to pass the pathname...
authorNick Downing <nick.downing@lifx.co>
Wed, 12 Feb 2020 07:29:31 +0000 (18:29 +1100)
committerNick Downing <nick.downing@lifx.co>
Wed, 12 Feb 2020 07:29:31 +0000 (18:29 +1100)
Site.js

diff --git a/Site.js b/Site.js
index 7b7e7a8..7773fce 100644 (file)
--- a/Site.js
+++ b/Site.js
@@ -59,6 +59,9 @@ let Site = function(resources, root, options/*, prev_site*/) {
         '.json': 'application/json; charset=utf-8',
         '.png': 'image/png',
         '.svg': 'image/svg+xml',
+        '.ttf': 'application/octet-stream',
+        '.woff': 'font/woff',
+        '.woff2': 'font/woff2',
         '.xml': 'text/xml; charset=utf-8'
       }
     },
@@ -501,7 +504,7 @@ Site.prototype.serve_file = async function(env, pathname) {
 }
 
 Site.prototype.serve_dir = async function(env, pathname, components) {
-  if (await this.serve_jst(env, pathname + '.dir.jst', components))
+  if (await this.serve_jst(env, pathname + '.dir.jst', pathname, components))
     return
 
   let stats
@@ -519,7 +522,7 @@ Site.prototype.serve_dir = async function(env, pathname, components) {
       env,
       components.length > 1 ?
         `not directory ${pathname}` :
-        `unknown extension "${extension}" in ${env.parsed_url.pathname}`
+        `unknown file type in ${env.parsed_url.pathname}`
     )
     return
   }