Fix url parsing.

This commit is contained in:
John-David Dalton
2014-05-06 22:09:25 -07:00
parent 086e1e1a74
commit f09ae1e2e3

View File

@@ -299,7 +299,6 @@ function optionToValue(name, string) {
* @private * @private
*/ */
function onJobRemove(error, res, body) { function onJobRemove(error, res, body) {
console.log('removed job id ' + this.id + ': ' + this.url);
this.id = this.testId = this.url = null; this.id = this.testId = this.url = null;
this.removing = false; this.removing = false;
this.emit('remove'); this.emit('remove');
@@ -314,8 +313,8 @@ function onJobRemove(error, res, body) {
* @param {Object} body The response body JSON object. * @param {Object} body The response body JSON object.
*/ */
function onJobStart(error, res, body) { function onJobStart(error, res, body) {
var testId = _.first(_.result(body, 'js tests')), var statusCode = _.result(res, 'statusCode'),
statusCode = _.result(res, 'statusCode'), testId = _.first(_.result(body, 'js tests')),
tunnel = this.tunnel; tunnel = this.tunnel;
this.starting = false; this.starting = false;
@@ -353,10 +352,10 @@ function onJobStart(error, res, body) {
*/ */
function onJobStatus(error, res, body) { function onJobStatus(error, res, body) {
var completed = _.result(body, 'completed'), var completed = _.result(body, 'completed'),
data = _.result(body, 'js tests', [{}])[0], data = _.first(_.result(body, 'js tests')),
jobResult = data.result, jobResult = _.result(data, 'result'),
jobStatus = data.status, jobStatus = _.result(data, 'status'),
jobUrl = data.url, jobUrl = _.result(data, 'url'),
options = this.options, options = this.options,
platform = options.platforms[0], platform = options.platforms[0],
description = browserName(platform[1]) + ' ' + platform[2] + ' on ' + capitalizeWords(platform[0]), description = browserName(platform[1]) + ' ' + platform[2] + ' on ' + capitalizeWords(platform[0]),
@@ -367,13 +366,14 @@ function onJobStatus(error, res, body) {
tunnel = this.tunnel; tunnel = this.tunnel;
this.checking = false; this.checking = false;
this.id = _.last(url.parse(jobUrl).pathname.split('/'));
this.url = jobUrl;
if (!this.running || this.stopping) { if (!this.running || this.stopping) {
return; return;
} }
this.emit('status', jobStatus); this.emit('status', jobStatus);
if (jobUrl) {
this.id = _.last(url.parse(jobUrl).pathname.split('/'));
this.url = jobUrl;
}
if (!completed && !expired) { if (!completed && !expired) {
this._timerId = setTimeout(_.bind(this.status, this), this.statusInterval); this._timerId = setTimeout(_.bind(this.status, this), this.statusInterval);
return; return;