From de990f0765c55b2995b8714a0cf1f0e3603664d5 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Mon, 27 Jul 2015 12:41:14 -0700 Subject: [PATCH] debug the html should the redirectUrl detection fail --- cloudron.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cloudron.js b/cloudron.js index c653c39..6d74460 100644 --- a/cloudron.js +++ b/cloudron.js @@ -41,7 +41,12 @@ Cloudron.prototype.getOauthToken = function (user) { var sessionCookies = res.headers['set-cookie']; // always an array ///////// should get redirected to login form with a script tag (to workaround chrome issue with redirects+cookies) - var urlp = url.parse(res.text.match(/window.location.href = "(.*)"/)[1]); + var redirectUrl = res.text.match(/window.location.href = "(.*)"/); + if (!redirectUrl) { + debug('Could not determine redirected url', res.text); + assert(false); + } + var urlp = url.parse(redirectUrl[1]); ////////// get the login form (api/v1/session/login) res = request.get(this._origin + urlp.pathname).set('cookie', sessionCookies[0]).query(urlp.query).end();