Skip to content

Commit

Permalink
Added path option
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonOehlman committed Aug 11, 2011
1 parent 06aa48a commit b4f2eba
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/PJsonCouch.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -526,22 +526,25 @@ var PJsonCouch = function (options) {


this.buildRequest = function (method, url) { this.buildRequest = function (method, url) {
if (!url.db && !url.serverAction) url.db = myDB; if (!url.db && !url.serverAction) url.db = myDB;
var qsparams = Utils.smartQueryString(url.args);
options.path = options.path + Utils.decodeGetData(url); var qsparams = Utils.smartQueryString(url.args),
options.method = method; reqOpts = Utils.clone(options);
options.path = (qsparams === "") ? options.path : options.path + "?" + qsparams;
reqOpts.path += Utils.decodeGetData(url);
reqOpts.method = method;
reqOpts.path = (qsparams === "") ? options.path : options.path + "?" + qsparams;


if (method !== "GET") { if (method !== "GET") {
options.headers["Content-Type"] = "application/json"; reqOpts.headers["Content-Type"] = "application/json";
} }


if (mySession !== "") { 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 { } else {
return new PJsonCouch(options); return new PJsonCouch(options);
Expand Down

0 comments on commit b4f2eba

Please sign in to comment.