fix: Remove Number() conversions that corrupt uint64 IDs
JavaScript's Number type cannot accurately represent uint64 values exceeding Number.MAX_SAFE_INTEGER (2^53-1). Converting these IDs to numbers causes precision loss and API errors. Root cause found: - match/[id]/+layout.ts: `Number(params.id)` corrupted match IDs - player/[id]/+page.ts: `Number(params.id)` corrupted player IDs Example of the bug: - URL param: "3638078243082338615" (correct) - After Number(): 3638078243082339000 (rounded!) - API response: "Match 3638078243082339000 not found" Changes: - Remove Number() conversions in route loaders - Keep params.id as string throughout the application - Update API functions to only accept string (not string | number) - Update MatchesQueryParams.player_id type to string - Add comprehensive transformers for legacy API responses - Transform player stats: duo→mk_2, triple→mk_3, steamid64→id - Build full Steam avatar URLs - Make share_code optional (not always present) This ensures uint64 IDs maintain full precision from URL → API → response. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,9 +3,9 @@ import { api } from '$lib/api';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
const playerId = Number(params.id);
|
||||
const playerId = params.id; // Keep as string to preserve uint64 precision
|
||||
|
||||
if (isNaN(playerId) || playerId <= 0) {
|
||||
if (!playerId || playerId.trim() === '') {
|
||||
throw error(400, 'Invalid player ID');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user