Skip to content

Commit

Permalink
Update normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Nov 10, 2024
1 parent abe288f commit 4997473
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions app/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ const theme2Color = {
frensday2024: '#FFF3E8',
};

const try_normalize = (name: string) => {
const ens_name = decodeURIComponent(name);

try {
return ens_normalize(ens_name.toLowerCase());
} catch {
return name;
}
};

export default async function ({
params: { slug },
searchParams: { event, iykRef },
Expand All @@ -34,13 +44,9 @@ export default async function ({
searchParams: { event?: string; iykRef?: string };
}) {
const raw_name = slug;
const name = ens_normalize(raw_name.toLowerCase());
const name = try_normalize(raw_name);
const ad_class: string = theme2Class[event] || 'theme-generic';

if (raw_name.toLowerCase() !== name) {
throw new Error('Invalid ENS name');
}

const [enstate, farcaster, iykData] = await Promise.all([
useEnstate(name),
useWarpcast(name),
Expand Down Expand Up @@ -119,13 +125,9 @@ export async function generateMetadata({
searchParams: { event?: string; iykRef?: string };
}) {
const raw_name = slug;
const name = ens_normalize(raw_name.toLowerCase());
const name = try_normalize(raw_name);
const theme_color = theme2Color[event] || '#F6F6F6';

if (raw_name.toLowerCase() !== name) {
throw new Error('Invalid ENS name');
}

const data = await useEnstate(name);

return {
Expand Down

0 comments on commit 4997473

Please sign in to comment.