[Pkg-javascript-commits] [node-static] 40/151: support absolute paths (Charlie Robbins)

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Tue Jan 7 23:17:57 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 5a69074de3af424dd167461039e00d6128ab7a8c
Author: cloudhead <alexis at cloudhead.io>
Date:   Sat Apr 30 18:44:51 2011 -0400

    support absolute paths (Charlie Robbins)
---
 lib/node-static.js | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/node-static.js b/lib/node-static.js
index 4335768..0db99c4 100644
--- a/lib/node-static.js
+++ b/lib/node-static.js
@@ -212,7 +212,7 @@ this.Server.prototype.respond = function (pathname, status, _headers, files, sta
             finish(status, _headers);
         } else {
             this.stream(pathname, files, new(buffer.Buffer)(stat.size), res, function (e, buffer) {
-                if (e) { return finish(null, {}) }
+                if (e) { return finish(500, {}) }
                 exports.store[key] = {
                     stat:      stat,
                     buffer:    buffer,
@@ -226,11 +226,13 @@ this.Server.prototype.respond = function (pathname, status, _headers, files, sta
 
 this.Server.prototype.stream = function (pathname, files, buffer, res, callback) {
     (function streamFile(files, offset) {
-        var file = files.shift();
+        var file = files.shift(), path;
 
         if (file) {
+            file = file[0] === '/' ? file : path.join(pathname || '.', file);
+
             // Stream the file to the client
-            fs.createReadStream(path.join(pathname || '.', file), {
+            fs.createReadStream(file, {
                 flags: 'r',
                 mode: 0666
             }).on('data', function (chunk) {

-- 
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