Allow case-insensitive player username lookups

This commit is contained in:
Alec LaLonde
2021-02-25 16:17:35 -07:00
parent 18d52cf5bf
commit e1c5322421

View File

@@ -180,14 +180,17 @@ export const getStaticPaths: GetStaticPaths<QueryParams> = async () => {
export const getStaticProps = async (
context: GetStaticPropsContext<QueryParams>,
) => {
const username = context.params?.username?.toLowerCase();
// usernames in the DB are lowercase. This essentially
// makes this page's router variable case-insensitive.
const username = context.params?.username?.toLowerCase();
const player = await getPlayer(username);
let player = null;
if (username != null) {
player = await getPlayer(username?.toLowerCase());
}
return {
props: {
player: player === undefined ? null : player, // must be serializable
player: player || null, // must be serializable
},
revalidate: 1,
};