mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-01-24 13:47:57 -05:00
Redirect to the proper player page URL when appropriate
This commit is contained in:
@@ -180,12 +180,27 @@ 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.
|
||||
let player = null;
|
||||
if (username != null) {
|
||||
player = await getPlayer(username?.toLowerCase());
|
||||
const username = context.params?.username;
|
||||
if (username == null) {
|
||||
return {
|
||||
redirect: {
|
||||
desination: '/',
|
||||
permanent: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let player = await getPlayer(username);
|
||||
if (player == null) {
|
||||
player = await getPlayer(username.toLowerCase());
|
||||
if (player != null) {
|
||||
return {
|
||||
redirect: {
|
||||
destination: `/player/${username.toLowerCase()}`,
|
||||
permanent: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user