Permalink
Browse files

Added path option

  • Loading branch information...
1 parent 06aa48a commit b4f2eba5fdbfa5d76bb92fcd015c3aeb8507d5b9 @DamonOehlman DamonOehlman committed Aug 11, 2011
Showing with 11 additions and 8 deletions.
  1. +11 −8 lib/PJsonCouch.js
View
@@ -526,22 +526,25 @@ var PJsonCouch = function (options) {
this.buildRequest = function (method, url) {
if (!url.db && !url.serverAction) url.db = myDB;
- var qsparams = Utils.smartQueryString(url.args);
- options.path = options.path + Utils.decodeGetData(url);
- options.method = method;
- options.path = (qsparams === "") ? options.path : options.path + "?" + qsparams;
+
+ var qsparams = Utils.smartQueryString(url.args),
+ reqOpts = Utils.clone(options);
+
+ reqOpts.path += Utils.decodeGetData(url);
+ reqOpts.method = method;
+ reqOpts.path = (qsparams === "") ? options.path : options.path + "?" + qsparams;
if (method !== "GET") {
- options.headers["Content-Type"] = "application/json";
+ reqOpts.headers["Content-Type"] = "application/json";
}
if (mySession !== "") {
- options.headers["Cookie"] = "AuthSession=" + mySession;
+ reqOpts.headers["Cookie"] = "AuthSession=" + mySession;
}
- options.headers["User-Agent"] = "PJsonCouch (node.js client for CouchDB) https://github.com/landeiro/PJsonCouch <landeiro@gmail.com>";
+ reqOpts.headers["User-Agent"] = "PJsonCouch (node.js client for CouchDB) https://github.com/landeiro/PJsonCouch <landeiro@gmail.com>";
- return Utils.clone(options);
+ return reqOpts;
};
} else {
return new PJsonCouch(options);

0 comments on commit b4f2eba

Please sign in to comment.