mirror of
https://github.com/maxswa/osrs-json-hiscores.git
synced 2025-10-15 10:19:04 +00:00
Add URL builders
This commit is contained in:
@@ -1,5 +1,30 @@
|
|||||||
import { Gamemode } from '../types';
|
import { Gamemode, Category } from '../types';
|
||||||
import { BASE_URL, GAMEMODE_URL, STATS_URL } from './constants';
|
import {
|
||||||
|
BASE_URL,
|
||||||
|
GAMEMODE_URL,
|
||||||
|
STATS_URL,
|
||||||
|
SCORES_URL,
|
||||||
|
SKILLS,
|
||||||
|
OTHER,
|
||||||
|
} from './constants';
|
||||||
|
|
||||||
export const getStatsURL = (gamemode: Gamemode, rsn: string) =>
|
export const getStatsURL = (gamemode: Gamemode, rsn: string) =>
|
||||||
`${BASE_URL}${GAMEMODE_URL[gamemode]}${STATS_URL}${encodeURIComponent(rsn)}`;
|
`${BASE_URL}${GAMEMODE_URL[gamemode]}${STATS_URL}${encodeURIComponent(rsn)}`;
|
||||||
|
|
||||||
|
export const getPlayerTableURL = (gamemode: Gamemode, rsn: string) =>
|
||||||
|
`${BASE_URL}${
|
||||||
|
GAMEMODE_URL[gamemode]
|
||||||
|
}${SCORES_URL}table=0&user=${encodeURIComponent(rsn)}`;
|
||||||
|
|
||||||
|
export const getHiscoresPageURL = (
|
||||||
|
gamemode: Gamemode,
|
||||||
|
category: Category,
|
||||||
|
page: number
|
||||||
|
) => {
|
||||||
|
const table = [...SKILLS, ...OTHER];
|
||||||
|
return `${BASE_URL}${GAMEMODE_URL[gamemode]}${SCORES_URL}${
|
||||||
|
table.includes(category)
|
||||||
|
? `table=${table.indexOf(category)}`
|
||||||
|
: `category_type=1&table=${OTHER.indexOf(category)}`
|
||||||
|
}&page=${page}`;
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user