diff --git a/lib/cradle.js b/lib/cradle.js index 7700ff6..b0e5f55 100644 --- a/lib/cradle.js +++ b/lib/cradle.js @@ -67,6 +67,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.auth && this.auth.user) { // Deprecation warning @@ -111,6 +118,7 @@ cradle.Connection.prototype.rawRequest = function (method, path, options, data, path = (path || '/').replace(/https?:\/\//, '').replace(/\/{2,}/g, '/'); if (path.charAt(0) !== '/') { path = '/' + path } + if (this.path_prefix) { path = this.path_prefix + path } if (options && Object.keys(options).length) { for (var k in options) { @@ -685,3 +693,5 @@ cradle.merge = function (target) { }); return target; } + +