Skip to content

Commit 759a724

Browse files
author
Justin
committed
2 parents d783632 + 79f252d commit 759a724

1 file changed

Lines changed: 25 additions & 11 deletions

File tree

src/SteamWebAPI2/Models/SteamId.cs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -261,31 +261,45 @@ public async Task ResolveAsync(string value)
261261
{
262262
string profileId = uriResult.Segments[2];
263263

264-
// try to parse the 3rd segment as a 64-bit Steam ID (http://steamcommunity.com/profiles/762541427451 for example)
265-
bool isSteamId64 = ulong.TryParse(profileId, out steamId);
266-
267-
// the third segment isn't a 64-bit Steam ID, check if it's a profile name which resolves to a 64-bit Steam ID
268-
if (!isSteamId64)
264+
// if a user has a vanity name setup in their steam profile, the steam profile url will be in the format of:
265+
// http://steamcommunity.com/id/<vanity name>
266+
// otherwise, the format will be:
267+
// http://steamcommunity.com/profiles/<64-bit Steam ID>
268+
if (uriResult.Segments[1] == "id/")
269269
{
270270
steamId = await ResolveSteamIdFromValueAsync(steamUser, profileId);
271+
ConstructFromSteamId64(steamId);
272+
ResolvedFrom = SteamIdResolvedFrom.SteamCommunityUri;
273+
}
274+
else if (uriResult.Segments[1] == "profiles/")
275+
{
276+
bool isSteamId64 = ulong.TryParse(profileId, out steamId);
277+
278+
if (isSteamId64)
279+
{
280+
ConstructFromSteamId64(steamId);
281+
ResolvedFrom = SteamIdResolvedFrom.SteamCommunityUri;
282+
}
283+
else
284+
{
285+
throw new InvalidSteamCommunityUriException(ErrorMessages.InvalidSteamCommunityUri);
286+
}
287+
}
288+
else
289+
{
290+
throw new InvalidSteamCommunityUriException(ErrorMessages.InvalidSteamCommunityUri);
271291
}
272-
273-
ConstructFromSteamId64(steamId);
274292
}
275293
else
276294
{
277295
throw new InvalidSteamCommunityUriException(ErrorMessages.InvalidSteamCommunityUri);
278296
}
279-
280-
ResolvedFrom = SteamIdResolvedFrom.SteamCommunityUri;
281297
}
282298
else
283299
{
284300
// not a 64-bit Steam ID and not a uri, try to just resolve it as if it was a Steam Community Profile Name
285301
steamId = await ResolveSteamIdFromValueAsync(steamUser, value);
286-
287302
ConstructFromSteamId64(steamId);
288-
289303
ResolvedFrom = SteamIdResolvedFrom.SteamCommunityProfileName;
290304
}
291305
}

0 commit comments

Comments
 (0)