Skip to content
This repository has been archived by the owner on May 9, 2018. It is now read-only.

Commit

Permalink
Pull request flatiron#128
Browse files Browse the repository at this point in the history
  • Loading branch information
ndrut committed Aug 5, 2013
1 parent 6e0ebff commit 1eb7348
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/cradle.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ cradle.Connection = function Connection(/* variable args */) {
this.host = this.host.replace(protocolPattern, '');
}

if (this.host.indexOf('/') != -1) {
var tmp = this.host.split('/');
this.host = tmp.shift();
this.path_prefix = '/' + tmp.join('/');
}


if (this.protocol === 'https') this.options.secure = true;

if (!this.protocol) {
Expand Down Expand Up @@ -132,6 +139,7 @@ cradle.Connection.prototype.rawRequest = function (options, callback) {
}

// Set client-wide headers
<<<<<<< HEAD
Object.keys(this.options.headers).forEach(function (header) {
options.headers[header] = self.options.headers[header];
});
Expand All @@ -140,6 +148,20 @@ cradle.Connection.prototype.rawRequest = function (options, callback) {
for (var k in options.query) {
if (typeof(options.query[k]) === 'boolean') {
options.query[k] = String(options.query[k]);
=======
for (var h in this.options.headers) {
headers[h] = this.options.headers[h];
}

path = (path || '/').replace(/https?:\/\//, '').replace(/\/{2,}/g, '/');
if (this.path_prefix) { path = this.path_prefix + path }
if (path.charAt(0) !== '/') { path = '/' + path }
if (options && Object.keys(options).length) {
for (var k in options) {
if (typeof(options[k]) === 'boolean') {
options[k] = String(options[k]);
>>>>>>> f9d23f3... support for couchdb in a subdirectory
}
}
options.path += '?' + querystring.stringify(options.query);
Expand Down Expand Up @@ -308,4 +330,10 @@ cradle.merge = function (target) {
});
});
return target;
<<<<<<< HEAD
};
=======
}


>>>>>>> f9d23f3... support for couchdb in a subdirectory

0 comments on commit 1eb7348

Please sign in to comment.