[Pkg-javascript-commits] [node-static] 59/151: fixed issue regarding missing trailing slash in URL when using default file "index.html"

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Tue Jan 7 23:17:58 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository node-static.

commit 2bbf68ac1adf6bdb2c3f44f4469ae1c5c8f1e5f9
Author: TeeTeeHaa <teeteehaa at teeteehaa.de>
Date:   Sun Jun 24 18:25:43 2012 +0300

    fixed issue regarding missing trailing slash in URL when using default file "index.html"
---
 lib/node-static.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/node-static.js b/lib/node-static.js
index 9399257..e6ac1c4 100644
--- a/lib/node-static.js
+++ b/lib/node-static.js
@@ -52,7 +52,14 @@ this.Server.prototype.serveDir = function (pathname, req, res, finish) {
 
     fs.stat(htmlIndex, function (e, stat) {
         if (!e) {
-            that.respond(null, 200, {}, [htmlIndex], stat, req, res, finish);
+            var status = 200;
+            var headers = {};
+            var originalPathname = decodeURI(url.parse(req.url).pathname);
+            if (originalPathname.length && originalPathname.charAt(originalPathname.length - 1) !== '/') {
+                status = 301;
+                headers['Location'] = originalPathname + '/';
+            }
+            that.respond(null, status, headers, [htmlIndex], stat, req, res, finish);
         } else {
             if (pathname in exports.store) {
                 streamFiles(exports.indexStore[pathname].files);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-static.git



More information about the Pkg-javascript-commits mailing list