diff --git a/karma.conf.js b/karma.conf.js index ad435f07a..96cd0cf38 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -11,7 +11,8 @@ module.exports = { // list of files / patterns to load in the browser files: [ "test/browser/*.js", - "test/both/*.js" + "test/both/*.js", + {pattern: "test/spec/v2/*.json", watched: false, included: false, served: true, nocache: false} ], diff --git a/lib/client.js b/lib/client.js index 437ee893e..1e1cf5bea 100644 --- a/lib/client.js +++ b/lib/client.js @@ -462,7 +462,7 @@ SwaggerClient.prototype.parseUri = function (uri) { var parts = urlParseRE.exec(uri); return { - scheme: parts[4].replace(':',''), + scheme: parts[4] ? parts[4].replace(':','') : undefined, host: parts[11], port: parts[12], path: parts[15] diff --git a/test/browser/http.js b/test/browser/http.js index f62105630..d04785191 100644 --- a/test/browser/http.js +++ b/test/browser/http.js @@ -171,4 +171,17 @@ describe('yaml http', function () { }); }); }); + + it('should support relative spec URLs as per #645', function(done) { + try { + new Swagger({ + url: '/base/test/spec/v2/test.json', + usePromise: true + }).then(function(client) { + done(); + }); + } catch (exception) { + done(exception); + } + }); });