Skip to content

Commit

Permalink
chore(rest-explorer): remove redirect from /explorer/ to /explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondfeng committed Feb 8, 2019
1 parent 56126a0 commit d1f4243
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ describe('API Explorer (acceptance)', () => {
.expect(/<title>LoopBack API Explorer/);
});

it('redirects from "/explorer" to "/explorer/"', async () => {
it('exposes API Explorer at "/explorer"', async () => {
await request
.get('/explorer')
.expect(301)
.expect('location', '/explorer/');
.expect(200)
.expect('content-type', /html/)
.expect(/<title>LoopBack API Explorer/);
});

it('configures swagger-ui with OpenAPI spec url "/openapi.json', async () => {
Expand Down Expand Up @@ -92,8 +93,7 @@ describe('API Explorer (acceptance)', () => {

await request
.get('/openapi/ui')
.expect(301)
.expect('Location', '/openapi/ui/');
.expect(200, /<title>LoopBack API Explorer/);

await request.get('/explorer').expect(404);
});
Expand Down
3 changes: 1 addition & 2 deletions packages/rest-explorer/src/rest-explorer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export class RestExplorerComponent implements Component {
) {
const explorerPath = config.path || '/explorer';

this.registerControllerRoute('get', explorerPath, 'indexRedirect');
this.registerControllerRoute('get', explorerPath + '/', 'index');
this.registerControllerRoute('get', explorerPath, 'index');

application.static(explorerPath, swaggerUI.getAbsoluteFSPath());

Expand Down
4 changes: 0 additions & 4 deletions packages/rest-explorer/src/rest-explorer.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ export class ExplorerController {
this.openApiSpecUrl = this.getOpenApiSpecUrl(restConfig);
}

indexRedirect() {
this.response.redirect(301, this.request.url + '/');
}

index() {
const data = {
openApiSpecUrl: this.openApiSpecUrl,
Expand Down

0 comments on commit d1f4243

Please sign in to comment.