Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

if api root contains finishing slash, removes it before adding specif…

…ic path
  • Loading branch information...
commit 07996338f535b7a96a32b55d78580908058ed739 1 parent e227b01
@bnjbvr authored
Showing with 10 additions and 2 deletions.
  1. +10 −2 lib/tent.coffee
View
12 lib/tent.coffee
@@ -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'
@
Please sign in to comment.
Something went wrong with that request. Please try again.