Fixed crashes when checking non-string HTTP responses (fixes #94)

This commit is contained in:
Alexander Corn 2016-03-14 21:39:45 -04:00
parent fe007811a5
commit 5880e922ab

View File

@ -105,14 +105,14 @@ SteamCommunity.prototype._checkHttpError = function(err, response, callback) {
SteamCommunity.prototype._checkCommunityError = function(html, callback) {
var err;
if(html && html.match(/<h1>Sorry!<\/h1>/)) {
if(typeof html === 'string' && html.match(/<h1>Sorry!<\/h1>/)) {
var match = html.match(/<h3>(.+)<\/h3>/);
err = new Error(match ? match[1] : "Unknown error occurred");
callback(err);
return err;
}
if (html && html.match(/g_steamID = false;/) && html.match(/<h1>Sign In<\/h1>/)) {
if (typeof html === 'string' && html.match(/g_steamID = false;/) && html.match(/<h1>Sign In<\/h1>/)) {
err = new Error("Not Logged In");
callback(err);
this._notifySessionExpired(err);
@ -123,7 +123,7 @@ SteamCommunity.prototype._checkCommunityError = function(html, callback) {
};
SteamCommunity.prototype._checkTradeError = function(html, callback) {
if (!html) {
if (typeof html !== 'string') {
return false;
}