steamutils 1.4.84 → 1.4.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +28 -33
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1209,7 +1209,7 @@ export default class SteamUser {
1209
1209
  }
1210
1210
  _response = await axios.request(config);
1211
1211
  } catch (e) {
1212
- if (e.errno !== -3008) {
1212
+ if (e.errno !== -3008 && e.code !== "ECONNRESET") {
1213
1213
  console.error(e);
1214
1214
  }
1215
1215
  }
@@ -1266,6 +1266,29 @@ export default class SteamUser {
1266
1266
  );
1267
1267
 
1268
1268
  if (response) {
1269
+ const html = response?.data;
1270
+ if (html && typeof html === "string") {
1271
+ const $ = cheerio.load(html.replaceAll(/[\t\n\r]/gi, "").trim());
1272
+ const title = $("head > title").text().trim();
1273
+ const errorMsg = $("#error_msg").text().trim();
1274
+ const headline = $("#headline").text().trim();
1275
+
1276
+ if (title && SteamErrorTitle.includes(title)) {
1277
+ return new ResponseError({
1278
+ message: errorMsg || "Steam Community :: Error",
1279
+ steamId: self._steamIdUser,
1280
+ originalURL,
1281
+ });
1282
+ } else if (title === "Error" && headline === "Something Went Wrong") {
1283
+ return new ResponseError({
1284
+ message: headline,
1285
+ detail: $("#message").text().trim(),
1286
+ steamId: self._steamIdUser,
1287
+ originalURL,
1288
+ });
1289
+ }
1290
+ }
1291
+
1269
1292
  switch (response.status) {
1270
1293
  case 302: {
1271
1294
  if (isRedirect) {
@@ -1298,38 +1321,10 @@ export default class SteamUser {
1298
1321
  break;
1299
1322
  }
1300
1323
  case 200: {
1301
- const html = response?.data;
1302
- let isError = false;
1303
- if (html && typeof html === "string") {
1304
- const $ = cheerio.load(html.replaceAll(/[\t\n\r]/gi, "").trim());
1305
- const title = $("head > title").text().trim();
1306
- const errorMsg = $("#error_msg").text().trim();
1307
- const headline = $("#headline").text().trim();
1308
-
1309
- if (title && SteamErrorTitle.includes(title)) {
1310
- isError = true;
1311
- response = new ResponseError({
1312
- message: errorMsg || "Steam Community :: Error",
1313
- steamId: self._steamIdUser,
1314
- originalURL,
1315
- });
1316
- } else if (title === "Error" && headline === "Something Went Wrong") {
1317
- isError = true;
1318
- response = new ResponseError({
1319
- message: headline,
1320
- detail: $("#message").text().trim(),
1321
- steamId: self._steamIdUser,
1322
- originalURL,
1323
- });
1324
- }
1325
- }
1326
-
1327
- if (!isError) {
1328
- const indexCookie = self._cookies.indexOf(cookie);
1329
- if (indexCookie > -1 && indexCookie !== 0) {
1330
- self._cookies.splice(indexCookie);
1331
- self._cookies.unshift(cookie);
1332
- }
1324
+ const indexCookie = self._cookies.indexOf(cookie);
1325
+ if (indexCookie > -1 && indexCookie !== 0) {
1326
+ self._cookies.splice(indexCookie);
1327
+ self._cookies.unshift(cookie);
1333
1328
  }
1334
1329
 
1335
1330
  return response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.4.84",
3
+ "version": "1.4.86",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.6",