Skip to content

Commit

Permalink
fix: Fix extra slash if basePath is not present
Browse files Browse the repository at this point in the history
fixes #201
  • Loading branch information
RomanHotsiy committed Feb 14, 2017
1 parent defef01 commit a5c03ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils/spec-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class SpecManager {
}

let host = this._schema.host || urlParts.host;
this.basePath = this._schema.basePath || '/';
this.basePath = this._schema.basePath || '';
this.apiUrl = protocol + '://' + host + this.basePath;
if (this.apiUrl.endsWith('/')) {
this.apiUrl = this.apiUrl.substr(0, this.apiUrl.length - 1);
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/SpecManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ describe('Utils', () => {
specMgr.apiUrl.should.be.equal('http://petstore.swagger.io/v2');
});

it('should use empty basePath when basePath is not present', () => {
specMgr._schema.basePath = undefined;
specMgr._url = 'https://petstore.swagger.io';
specMgr.init();
specMgr.basePath.should.be.equal('');
});

describe('byPointer method', () => {
it('should return correct schema part', ()=> {
let part = specMgr.byPointer('/tags/0');
Expand Down

0 comments on commit a5c03ab

Please sign in to comment.