Compare commits

...

6 Commits

Author SHA1 Message Date
Alexander Corn
26effb27fe 3.19.2 2016-03-14 21:39:55 -04:00
Alexander Corn
5880e922ab Fixed crashes when checking non-string HTTP responses (fixes #94) 2016-03-14 21:39:45 -04:00
Alexander Corn
fe007811a5 Bumped cheerio version 2016-03-08 01:56:31 -05:00
Alexander Corn
7b882c8439 Updated readme 2016-03-08 01:53:45 -05:00
Alexander Corn
6c4cb9e62f 3.19.1 2016-03-08 01:37:29 -05:00
Alexander Corn
2300081d43 Only fire the callback for blocked requests if one was provided 2016-03-08 01:37:20 -05:00
3 changed files with 20 additions and 16 deletions

View File

@@ -9,12 +9,15 @@ This module provides an easy interface for the Steam Community website. This mod
It supports Steam Guard and CAPTCHAs.
# Installation
Install it from npm:
$ npm install steamcommunity
**Have a question about the module or coding in general? *Do not create a GitHub issue.* GitHub issues are for feature
requests and bug reports. Instead, post in the [dedicated forum](https://dev.doctormckay.com/forum/8-node-steamcommunity/).
Such issues may be ignored!**
# Documentation
As of version 1.0.0, documentation is on the [GitHub wiki](https://github.com/DoctorMcKay/node-steamcommunity/wiki).
Documentation is available on the [GitHub wiki](https://github.com/DoctorMcKay/node-steamcommunity/wiki).
# Support
Report bugs on the [issue tracker](https://github.com/DoctorMcKay/node-steamcommunity/issues) or ask questions
on the [dedicated forum](https://dev.doctormckay.com/forum/8-node-steamcommunity/).

View File

@@ -38,17 +38,18 @@ SteamCommunity.prototype.httpRequest = function(uri, options, callback, source)
continued = true;
if (err) {
callback(err);
if (callback) {
callback(err);
}
return;
}
self.request(options, function (err, response, body) {
var hasCallback = !!callback;
var httpError = options.checkHttpError !== false && self._checkHttpError(err, response, callback);
var communityError = !options.json && options.checkCommunityError !== false && self._checkCommunityError(body, httpError ? function () {
} : callback); // don't fire the callback if hasHttpError did it already
var tradeError = !options.json && options.checkTradeError !== false && self._checkTradeError(body, httpError || communityError ? function () {
} : callback); // don't fire the callback if either of the previous already did
var communityError = !options.json && options.checkCommunityError !== false && self._checkCommunityError(body, httpError ? function () {} : callback); // don't fire the callback if hasHttpError did it already
var tradeError = !options.json && options.checkTradeError !== false && self._checkTradeError(body, httpError || communityError ? function () {} : callback); // don't fire the callback if either of the previous already did
self.emit('postHttpRequest', requestID, source, options, httpError || communityError || tradeError || null, response, body, {
"hasCallback": hasCallback,
@@ -104,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);
@@ -122,7 +123,7 @@ SteamCommunity.prototype._checkCommunityError = function(html, callback) {
};
SteamCommunity.prototype._checkTradeError = function(html, callback) {
if (!html) {
if (typeof html !== 'string') {
return false;
}

View File

@@ -1,6 +1,6 @@
{
"name": "steamcommunity",
"version": "3.19.0",
"version": "3.19.2",
"description": "Provides an interface for logging into and interacting with the Steam Community website",
"keywords": ["steam", "steam community"],
"homepage": "https://github.com/DoctorMcKay/node-steamcommunity",
@@ -17,7 +17,7 @@
"node-bignumber": "^1.2.1",
"steamid": "^0.3.1",
"xml2js": "^0.4.11",
"cheerio": "^0.19.0",
"cheerio": "^0.20.0",
"async": "^1.4.2",
"steam-totp": "^1.3.0"
},