aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJohannes Zellner <johannes@nebulon.de>2015-09-08 15:05:13 +0200
committerJohannes Zellner <johannes@nebulon.de>2015-09-08 15:05:13 +0200
commit7bb99aff6337ee30a74a71f587c9a58eb5d24cb3 (patch)
tree98fcb22db6a93a7946ce453cff6d60cd6d4a2520 /src
parentb9ad5d9155a65125f83071b409b4193ee97ce9d8 (diff)
downloadSurfer-7bb99aff6337ee30a74a71f587c9a58eb5d24cb3.tar.gz
Surfer-7bb99aff6337ee30a74a71f587c9a58eb5d24cb3.tar.zst
Surfer-7bb99aff6337ee30a74a71f587c9a58eb5d24cb3.zip
Use 222 status code to indicate folder listing and use stdout only for data
Diffstat (limited to 'src')
-rw-r--r--src/files.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/files.js b/src/files.js
index 3b28d3f..d12782d 100644
--- a/src/files.js
+++ b/src/files.js
@@ -54,7 +54,7 @@ function copyFile(source, target, cb) {
54} 54}
55 55
56function getAbsolutePath(filePath) { 56function getAbsolutePath(filePath) {
57 var absoluteFilePath = path.resolve(gBasePath, filePath); 57 var absoluteFilePath = path.resolve(path.join(gBasePath, filePath));
58 58
59 if (absoluteFilePath.indexOf(gBasePath) !== 0) return null; 59 if (absoluteFilePath.indexOf(gBasePath) !== 0) return null;
60 return absoluteFilePath; 60 return absoluteFilePath;
@@ -71,7 +71,7 @@ function get(req, res, next) {
71 debug('get', absoluteFilePath); 71 debug('get', absoluteFilePath);
72 72
73 if (result.isFile()) return res.sendFile(absoluteFilePath); 73 if (result.isFile()) return res.sendFile(absoluteFilePath);
74 if (result.isDirectory()) return res.status(200).send({ entries: fs.readdirSync(absoluteFilePath) }); 74 if (result.isDirectory()) return res.status(222).send({ entries: fs.readdirSync(absoluteFilePath) });
75 75
76 return next(new HttpError(500, 'unsupported type')); 76 return next(new HttpError(500, 'unsupported type'));
77 }); 77 });