Browse Source

Worked with PC/Windows file path

Reggie Chen 6 years ago
parent
commit
52d96e3381
1 changed files with 2 additions and 1 deletions
  1. 2 1
      index.js

+ 2 - 1
index.js

@@ -41,7 +41,8 @@ function readDirR(dir) {
     } else {
       if ((dir.indexOf('.yaml') !== -1) || (dir.indexOf('.js') !== -1) || (dir.indexOf('.html') !== -1)
       || (dir.indexOf('.json') !== -1))
-       return dir.replace(__dirname + '/public/', "/")
+       // a little hack to resolve serving file paths under PC/Windows file system...
+       return dir.replace(__dirname, '').replace(/\\/g, '/').replace('/public/',"/");
     }
 }