Permalink
Browse files

correcting bug in Document.id that caused design documents (and presu…

…mably local documents) to have the incorrect url generated
  • Loading branch information...
1 parent d66b8ca commit 9ed619471a0ebb81f001c4bbb11701983fbb24fa Dominic Barnes committed Apr 13, 2012
Showing with 15 additions and 8 deletions.
  1. +2 −7 lib/document.js
  2. +1 −1 package.json
  3. +12 −0 test/ddoc.js
View
@@ -22,16 +22,11 @@ Object.defineProperty(proto, "body", {
// dependent on url, but also affects the body
Object.defineProperty(proto, "id", {
get: function () {
- var path = this._url.pathname.split("/");
- if (path.length > 2 && path[2][0] === "_") {
- return path.slice(2, 4).join("/");
- } else {
- return path[2];
- }
+ return this._url.pathname.split("/").slice(2).join("/");
},
set: function (v) {
var path = this._url.pathname.split("/");
- path[2] = v;
+ path.splice(2, v.split("/").length, v);
this.body._id = v;
this._url.path = this._url.pathname = path.join("/");
}
View
@@ -3,7 +3,7 @@
"name": "couchdb-api",
"description": "An async wrapper for the CouchDB HTTP API, following Node.js conventions",
"keywords": [ "couchdb", "async", "nosql", "api", "http", "couch", "rest" ],
- "version": "1.1.3",
+ "version": "1.1.4",
"main": "index",
"homepage": "http://dominicbarnes.us/node-couchdb-api",
"repository": {
View
@@ -23,6 +23,18 @@ module.exports = {
},
"Design Document": {
+ "Get": function (done) {
+ ddoc.get(function (err, results) {
+ test.ifError(err, results);
+ done();
+ });
+ },
+ "Set": function (done) {
+ ddoc.save(function (err, results) {
+ test.ifError(err);
+ done();
+ });
+ },
"Information": function (done) {
var ret = ddoc.info(function (err, response) {
test.ifError(err);

0 comments on commit 9ed6194

Please sign in to comment.