steamutils 1.4.85 → 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.
- package/index.js +27 -32
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -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
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
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;
|