mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-03-01 13:50:16 +08:00
Check properties instead of SteamID proto (fixes #90)
This commit is contained in:
parent
46e16cc0b6
commit
b761b8108b
@ -1,9 +1,10 @@
|
||||
var SteamCommunity = require('../index.js');
|
||||
var Helpers = require('../components/helpers.js');
|
||||
var SteamID = require('steamid');
|
||||
var xml2js = require('xml2js');
|
||||
|
||||
SteamCommunity.prototype.getSteamGroup = function(id, callback) {
|
||||
if(typeof id !== 'string' && !(typeof id === 'object' && id.__proto__ === SteamID.prototype)) {
|
||||
if(typeof id !== 'string' && !Helpers.isSteamID(id)) {
|
||||
throw new Error("id parameter should be a group URL string or a SteamID object");
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
var SteamCommunity = require('../index.js');
|
||||
var Helpers = require('../components/helpers.js');
|
||||
var SteamID = require('steamid');
|
||||
var xml2js = require('xml2js');
|
||||
|
||||
SteamCommunity.prototype.getSteamUser = function(id, callback) {
|
||||
if(typeof id !== 'string' && !(typeof id === 'object' && id.__proto__ === SteamID.prototype)) {
|
||||
if(typeof id !== 'string' && !Helpers.isSteamID(id)) {
|
||||
throw new Error("id parameter should be a user URL string or a SteamID object");
|
||||
}
|
||||
|
||||
|
13
components/helpers.js
Normal file
13
components/helpers.js
Normal file
@ -0,0 +1,13 @@
|
||||
exports.isSteamID = function(input) {
|
||||
var keys = Object.keys(input);
|
||||
if (keys.length != 4) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure it has the keys we expect
|
||||
keys = keys.filter(function(item) {
|
||||
return ['universe', 'type', 'instance', 'accountid'].indexOf(item) != -1;
|
||||
});
|
||||
|
||||
return keys.length == 4;
|
||||
};
|
Loading…
Reference in New Issue
Block a user