Skip to content

Commit

Permalink
Merge c8127c0 into a73a728
Browse files Browse the repository at this point in the history
  • Loading branch information
svaj committed Dec 7, 2017
2 parents a73a728 + c8127c0 commit 19c10b7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,10 @@ module.exports = {
if (url.length > 1 && url.endsWith("/"))
url = url.slice(0, -1);

// Handle root case
if (url === "")
url = "/";

// Check the URL
if (this.routes && this.routes.length > 0) {
for(let i = 0; i < this.routes.length; i++) {
Expand Down
26 changes: 26 additions & 0 deletions test/integration/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,32 @@ describe("Test aliases", () => {
});
});

describe("Test root url alias", () => {
let broker;
let service;
let server;

beforeAll(() => {
[ broker, service, server] = setup({
routes: [{
aliases: {
"": "test.hello"
}
}]
})
})

it ("GET /", () => {
return request(server)
.get("/")
.expect(200)
.expect("Content-Type", "application/json; charset=utf-8")
.then(res => {
expect(res.body).toEqual("Hello Moleculer");
});
})
})

describe("Test REST shorthand aliases", () => {
let broker;
let service;
Expand Down

0 comments on commit 19c10b7

Please sign in to comment.