diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/nodeserver/server.js | 12 | 
1 files changed, 12 insertions, 0 deletions
| diff --git a/lib/nodeserver/server.js b/lib/nodeserver/server.js index 471bba94..54ae78fc 100644 --- a/lib/nodeserver/server.js +++ b/lib/nodeserver/server.js @@ -91,6 +91,18 @@ StaticServlet.prototype.handleRequest = function(req, res) {    var parts = path.split('/');    if (parts[parts.length-1].charAt(0) === '.')      return self.sendForbidden_(req, res, path); + +  // docs rewriting +  var REWRITE = /\/(guide|api|cookbook|misc|tutorial)\/.*$/, +      IGNORED = /(\.(css|js|png|jpg)$|partials\/.*\.html$)/, +      match; + +  if (!IGNORED.test(path) && (match = path.match(REWRITE))) { +      path = path.replace(match[0], '/index.html'); +      sys.puts('Rewrite to ' + path); +  } +  // end of docs rewriting +    fs.stat(path, function(err, stat) {      if (err)        return self.sendMissing_(req, res, path); | 
