Permalink
Browse files

* [fix] don't expose _id,_rev,resource on safeJSON

  • Loading branch information...
1 parent 4c9d0cb commit 1d3d5bafb82182c8aad8765f00d2b050185cfd98 @chbm chbm committed Aug 29, 2012
Showing with 6 additions and 2 deletions.
  1. +2 −2 lib/resourceful/resource.js
  2. +4 −0 test/resourceful-test.js
@@ -870,8 +870,8 @@ Resource.prototype.toJSON = function () {
Resource.prototype.safeJSON = function () {
var schema = this.constructor.schema;
return resourceful.clone(this.properties, function (key) {
- return key === '_id' || key === '_rev' || key === 'resource'
- || (schema.properties[key] && !schema.properties[key].restricted);
+ return !(key === '_id' || key === '_rev' || key === 'resource'
+ || (schema.properties[key] && schema.properties[key].restricted));
});
};
@@ -126,6 +126,10 @@ vows.describe('resourceful').addVows({
assert.ok(!restricted.title);
assert.ok(restricted.kind);
+
+ assert.ok(!restricted._rev);
+ assert.ok(!restricted._id);
+ assert.ok(!restricted.resource);
},
"should return the attributes, when `Object.keys` is called": function (r) {
var keys = Object.keys(r);

0 comments on commit 1d3d5ba

Please sign in to comment.