Skip to content

Commit

Permalink
* [fix] don't expose _id,_rev,resource on safeJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
chbm committed Aug 29, 2012
1 parent 4c9d0cb commit 1d3d5ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/resourceful/resource.js
Expand Up @@ -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));
});
};

Expand Down
4 changes: 4 additions & 0 deletions test/resourceful-test.js
Expand Up @@ -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);
Expand Down

0 comments on commit 1d3d5ba

Please sign in to comment.