@qgisk/steamresolver
Advanced tools
Comparing version 1.0.5 to 1.0.6
{ | ||
"name": "@qgisk/steamresolver", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Steam ID Lookup from custom urls and the other way around", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -36,3 +36,3 @@ # Steam ID Resolver for NodeJS | ||
// Create a function that gets a joke | ||
// Create a function that gets the custom url | ||
const get = async () => { | ||
@@ -39,0 +39,0 @@ const fromID = await Resolve.toCustomURL('76561198250920834'); |
@@ -86,3 +86,3 @@ const xmlParser = require('xml2js'); | ||
}) | ||
.catch((e) => new Error(`Error parsing data xml: ${e}`)); | ||
.catch((e) => e); | ||
@@ -89,0 +89,0 @@ const parseParams = (param) => { |
@@ -14,3 +14,3 @@ const fetch = require('isomorphic-unfetch'); | ||
* @public | ||
* @version 1.0.5 | ||
* @version 1.0.6 | ||
* @license MIT | ||
@@ -30,5 +30,3 @@ */ | ||
const res = await this._request(url); | ||
return res.customURL[0]; | ||
return this._request(url, 'customURL'); | ||
} | ||
@@ -47,5 +45,3 @@ | ||
const res = await this._request(url); | ||
return res.steamID64[0]; | ||
return this._request(url, 'steamID64'); | ||
} | ||
@@ -64,5 +60,3 @@ | ||
const res = await this._request(url); | ||
return res; | ||
return this._request(url); | ||
} | ||
@@ -81,5 +75,3 @@ | ||
const res = await this._request(url); | ||
return res; | ||
return this._request(url); | ||
} | ||
@@ -98,5 +90,3 @@ | ||
const res = await this._request(url); | ||
return res.groupID64[0]; | ||
return this._request(url, 'groupID64'); | ||
} | ||
@@ -115,5 +105,3 @@ | ||
const res = await this._request(url); | ||
return res; | ||
return this._request(url); | ||
} | ||
@@ -127,14 +115,22 @@ | ||
*/ | ||
async _request(url) { | ||
return fetch(`${url}?xml=1`) | ||
.then((res) => res.text()) | ||
.then((output) => { | ||
if (!Utils.doesInclude(output, '<?xml') && Utils.doesInclude(output, '<error>')) { | ||
// Check if output is steam group xml data before parsing it in order to provide correct group not found message | ||
return new Error('Resource cannot be found'); | ||
} | ||
async _request(url, output) { | ||
return new Promise((resolve, reject) => { | ||
fetch(`${url}?xml=1`) | ||
.then((res) => res.text()) | ||
.then(async (data) => { | ||
if (!Utils.doesInclude(data, '<?xml') && Utils.doesInclude(data, '<error>')) { | ||
// Check if output is steam group xml data before parsing it in order to provide correct group not found message | ||
reject(new Error('Resource cannot be found')); | ||
} | ||
return Utils.parseXML(output); | ||
}) | ||
.catch((e) => new Error(`Error trying to reach Steam: ${e}`)); | ||
const parsedData = await Utils.parseXML(data); | ||
if (output) { | ||
resolve(parsedData[output][0]); | ||
} | ||
resolve(parsedData); | ||
}) | ||
.catch((e) => reject(e)); | ||
}); | ||
} | ||
@@ -141,0 +137,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12172