mirror of
https://github.com/Pandipipas/scoreko-dev.git
synced 2026-06-06 03:32:06 +00:00
3a6289a2ea
- Added start.gg OAuth server and session management in startgg.ts - Implemented functions to fetch recent tournaments and tournament players from start.gg - Created utility functions for string and country code handling - Introduced Challonge OAuth server and services for tournament data fetching - Refactored shared types and utility functions for better organization - Updated scoreboard graphics to use new country resolution utilities - Removed legacy startgg.ts file to streamline codebase
29 lines
909 B
JavaScript
29 lines
909 B
JavaScript
export const getStringProp = (payload, key) => {
|
|
if (typeof payload !== 'object' || payload === null || !(key in payload))
|
|
return '';
|
|
const value = payload[key];
|
|
return typeof value === 'string' ? value.trim() : String(value ?? '').trim();
|
|
};
|
|
export const getNumberProp = (payload, keys) => {
|
|
for (const key of keys) {
|
|
const raw = payload[key];
|
|
if (typeof raw === 'number' && Number.isFinite(raw))
|
|
return raw;
|
|
if (typeof raw === 'string') {
|
|
const parsed = Number(raw);
|
|
if (Number.isFinite(parsed))
|
|
return parsed;
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
export const normalizeTournamentSlug = (value) => {
|
|
const trimmed = value.trim();
|
|
if (!trimmed)
|
|
return '';
|
|
return trimmed
|
|
.replace(/^https?:\/\/[^/]+\//i, '')
|
|
.replace(/^tournaments\//i, '')
|
|
.replace(/^\/+/, '');
|
|
};
|