Comparing version 0.0.9 to 0.1.0
@@ -21,4 +21,4 @@ // fileserver | ||
app.put("/*", putFileOrDir); | ||
app.del("/*/", delDir); | ||
app.del("/*", delFile); | ||
app.del(/^\/.+\/$/, delDir); | ||
app.del(/^\/.+[^\/]$/, delFile); | ||
app.use(function (err, req, res, next) { | ||
@@ -223,3 +223,3 @@ res.send(500, err); | ||
} else if (err && err.code === 'ENOTDIR') { | ||
sendCode(404, req, res, next, formatOutData(dirPath))(null); | ||
sendCode(400, req, res, next, formatOutData(dirPath))(null); | ||
} else { | ||
@@ -246,3 +246,3 @@ sendCode(200, req, res, next, formatOutData(dirPath))(err); | ||
} else if (err && err.code === 'EISDIR') { | ||
sendCode(404, req, res, next, formatOutData(dirPath))(null); | ||
sendCode(400, req, res, next, formatOutData(dirPath))(null); | ||
} else { | ||
@@ -249,0 +249,0 @@ sendCode(200, req, res, next, formatOutData(dirPath))(err); |
{ | ||
"name": "rest-fs", | ||
"version": "0.0.9", | ||
"version": "0.1.0", | ||
"description": "restful fileserver", | ||
@@ -5,0 +5,0 @@ "main": "fileserver.js", |
@@ -267,3 +267,3 @@ var Lab = require('lab'); | ||
.del(filePath+'/') | ||
.expect(404) | ||
.expect(400) | ||
.end(done); | ||
@@ -270,0 +270,0 @@ }); |
@@ -32,3 +32,3 @@ var Lab = require('lab'); | ||
req.send(opts); | ||
} | ||
} | ||
req.end(function(err, res){ | ||
@@ -58,3 +58,3 @@ if (err) { | ||
req.send(opts); | ||
} | ||
} | ||
req.end(function(err, res){ | ||
@@ -285,3 +285,3 @@ if (err) { | ||
if (err) { return done(err); } | ||
Lab.expect(res.statusCode).to.equal(404); | ||
Lab.expect(res.statusCode).to.equal(400); | ||
done(); | ||
@@ -302,3 +302,3 @@ }); | ||
Lab.test('try to delete folder', function (done) { | ||
Lab.test('try to delete folder with file api', function (done) { | ||
rmFile(baseFolder, function (err, res) { | ||
@@ -308,4 +308,6 @@ if (err) { | ||
} | ||
Lab.expect(res.statusCode).to.equal(403); | ||
return done(); | ||
if (res.statusCode === 400 || res.statusCode === 403){ | ||
return done(); | ||
} | ||
return new Error('should not delete folder'); | ||
}); | ||
@@ -333,3 +335,3 @@ }); | ||
}); | ||
Lab.after(function (done) { | ||
@@ -336,0 +338,0 @@ cleanBase(done); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56973
1603