Skip to content

Commit fcacbdd

Browse files
committed
Relative spec URL error fix #645.
1 parent e9bd43d commit fcacbdd

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

karma.conf.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ module.exports = {
1111
// list of files / patterns to load in the browser
1212
files: [
1313
"test/browser/*.js",
14-
"test/both/*.js"
14+
"test/both/*.js",
15+
{pattern: "test/spec/v2/*.json", watched: false, included: false, served: true, nocache: false}
1516
],
1617

1718

lib/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ SwaggerClient.prototype.parseUri = function (uri) {
462462
var parts = urlParseRE.exec(uri);
463463

464464
return {
465-
scheme: parts[4].replace(':',''),
465+
scheme: parts[4] ? parts[4].replace(':','') : undefined,
466466
host: parts[11],
467467
port: parts[12],
468468
path: parts[15]

test/browser/http.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,17 @@ describe('yaml http', function () {
171171
});
172172
});
173173
});
174+
175+
it('should support relative spec URLs as per #645', function(done) {
176+
try {
177+
new Swagger({
178+
url: '/base/test/spec/v2/test.json',
179+
usePromise: true
180+
}).then(function(client) {
181+
done();
182+
});
183+
} catch (exception) {
184+
done(exception);
185+
}
186+
});
174187
});

0 commit comments

Comments
 (0)