Commit 9bdc22c7 authored by analog-nico's avatar analog-nico
Browse files

Safe access of statusCode

parent e2991c12
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -16,15 +16,13 @@ function ownCallback(err, httpResponse, body) {
        } catch (e) { }
    }

    // FIXME: Access to httpResponse.statusCode could crash.

    if (err) {
        self._rp_reject({
            error: err,
            options: self._rp_options,
            response: httpResponse
        });
    } else if (self._rp_options.simple && !(/^2/.test('' + httpResponse.statusCode))) {
    } else if (self._rp_options.simple && _.isObject(httpResponse) && !(/^2/.test('' + httpResponse.statusCode))) {
        self._rp_reject({
            error: body,
            options: self._rp_options,