mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-02-06 07:27:03 +08:00
Fixed crashes when checking non-string HTTP responses (fixes #94)
This commit is contained in:
parent
fe007811a5
commit
5880e922ab
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user