Skip to content

Commit

Permalink
Merge branch 'with-params'
Browse files Browse the repository at this point in the history
  • Loading branch information
nairihar committed May 16, 2018
2 parents cb3245c + a1140ce commit 2231537
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/http/route/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@ export default class Route {

/* getters */
getAddress() {
const { address, } = _privates.get(this)
return address
const { address, parentRoute, } = _privates.get(this)
let myAddress = address
if (!address) {
myAddress = parentRoute.getAddress()
}
return myAddress
}

getUrl() {
const { parentRoute, address, } = _privates.get(this)
const { address, parentRoute, } = _privates.get(this)
let myAddress = address
if (!address) {
myAddress = parentRoute.getUrl()
Expand Down
5 changes: 4 additions & 1 deletion test/route_tree_params.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ describe('check api tree params functionality for rest apis', () => {
address,
routes: {
user: {
a: 'asd',
[Route.main]: '/user',
week: {
method: methods.GET,
Expand All @@ -28,6 +27,7 @@ describe('check api tree params functionality for rest apis', () => {
},
})
const userAddress = 'http://localhost:666/user'
const userJustAddress = 'http://localhost:666'
const signInAddress = 'http://localhost:666/auth/signIn'
const userWeekAddress = 'http://localhost:666/user/week'
it('user route address should be value of userAddress variable', () => {
Expand All @@ -39,4 +39,7 @@ describe('check api tree params functionality for rest apis', () => {
it('user.week route address should be value of userWeekAddress variable', () => {
assert.equal(api.user.week.getUrl(), userWeekAddress)
})
it('address of user.week route address should be value of userJustAddress variable', () => {
assert.equal(api.user.week.getAddress(), userJustAddress)
})
})

0 comments on commit 2231537

Please sign in to comment.