Skip to content

Commit

Permalink
if api root contains finishing slash, removes it before adding specif…
Browse files Browse the repository at this point in the history
…ic path
  • Loading branch information
Benjamin Bouvier committed Apr 9, 2013
1 parent e227b01 commit 0799633
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/tent.coffee
Expand Up @@ -88,14 +88,22 @@ class Client
r.run()

getApiRoot: (cb) ->
@getProfile (err, p) ->
if @apiRoot
cb null, @apiRoot
return

@getProfile (err, p) =>
if err
cb err
return

core = p[ "https://tent.io/types/info/core/v0.1.0" ]
if core and core.servers and core.servers.length > 0
cb null, core.servers[0]
@apiRoot = core.servers[0]
if @apiRoot[ @apiRoot.length-1 ] == '/'
@apiRoot = @apiRoot.slice 0, @apiRoot.length - 1

cb null, @apiRoot
else
cb 'profile key error: no core or servers'
@
Expand Down

0 comments on commit 0799633

Please sign in to comment.