Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion scripts/fetch-user-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function fetchUserInfo(username) {
// Auto-Migration Check & Routing
if (Array.isArray(data)) {
history = data;
} else {
} else if (data && typeof data === "object") {
// Safe object destructuring for the new profile structure
history = data.history || [];
badges = data.badges || [];
Expand Down Expand Up @@ -69,6 +69,8 @@ async function fetchUserInfo(username) {
await Promise.allSettled([livePromise]);

// Ensure history is sorted chronologically
// Guard against a corrupted history file (e.g. non-array `history` field)
history = Array.isArray(history) ? history : [];
history.sort((a, b) => new Date(a.date) - new Date(b.date));

return {
Expand Down
Loading