Added _myProfile helper to make calls to the user's profile URL

This commit is contained in:
Alexander Corn 2014-12-17 03:07:49 -05:00
parent 7f2a287c56
commit 0cb5eef1f8

View File

@ -130,4 +130,22 @@ SteamCommunity.prototype._checkCommunityError = function(html, callback) {
return false;
};
SteamCommunity.prototype._myProfile = function(endpoint, form, callback) {
var self = this;
this._request("https://steamcommunity.com/my", {"followRedirect": false}, function(err, response, body) {
if(err || response.statusCode != 302) {
callback(err || "HTTP error " + response.statusCode);
return;
}
var match = response.headers.location.match(/steamcommunity\.com(\/(id|profiles)\/[^\/]+)\/?/);
if(!match) {
callback("Can't get profile URL");
return;
}
(form ? self._request.post : self._request)("https://steamcommunity.com" + match[1] + "/" + endpoint, form ? {"form": form} : {}, callback);
});
};
require('./classes/CSteamGroup.js');