Comparing version 0.6.20 to 0.6.21
Baucis Change Log | ||
================= | ||
v0.6.21 | ||
------- | ||
Fix an issue where the `Location` response header would be set incorrectly. Special thanks to feychenie. | ||
v0.6.20 | ||
@@ -5,0 +10,0 @@ ------- |
@@ -58,4 +58,9 @@ // __Dependencies__ | ||
// If it's not a POST, send now because Location shouldn't be set. | ||
if (request.method !== 'POST') return response.json(documents); | ||
if (request.method !== 'POST') return response.json(documents); | ||
// Ensure there is a trailing slash on basePath for proper function of | ||
// url.resolve, otherwise the model's plural will be missing in the location | ||
// URL. | ||
if(!basePath.match(/\/$/)) basePath += '/'; | ||
// Otherwise, set the location and send JSON document(s). Don't set location if documents | ||
@@ -62,0 +67,0 @@ // don't have IDs for whatever reason e.g. custom middleware. |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://github.com/wprl/baucis", | ||
"version": "0.6.20", | ||
"version": "0.6.21", | ||
"main": "index.js", | ||
@@ -8,0 +8,0 @@ "scripts": { |
@@ -1,2 +0,2 @@ | ||
baucis v0.6.20 | ||
baucis v0.6.21 | ||
============== | ||
@@ -3,0 +3,0 @@ |
@@ -37,2 +37,18 @@ var expect = require('expect.js'); | ||
it('should correctly set location header when there is no trailing slash', function (done) { | ||
var options = { | ||
url: 'http://localhost:8012/api/v1/vegetables', | ||
json: { name: 'Tomato' } | ||
}; | ||
request.post(options, function (error, response, body) { | ||
if (error) return done(error); | ||
expect(response.statusCode).to.equal(201); | ||
expect(body._id).not.to.be.empty(); | ||
expect(response.headers.location).to.equal('/api/v1/vegetables/' + body._id); | ||
done(); | ||
}); | ||
}); | ||
it('should allow posting multiple documents at once', function (done) { | ||
@@ -39,0 +55,0 @@ var options = { |
564361
2972