Skip to content

Commit

Permalink
fix emoji encoding (#996)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkas authored Sep 12, 2024
1 parent 6f5780f commit 8b26996
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions apps/web/app/(basenames)/name/[username]/opengraph-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,25 @@ export async function generateImageMetadata({ params }: UsernameProfileProps) {
username = formatBaseEthDomain(username, base.id);
}

// Remove funky char which breaks OG image path
const alphanumericRegex = /[^a-zA-Z0-9]/g;
const sanitizedId = username.replace(alphanumericRegex, '');

return [
{
alt: `Basenames | ${username}`,
contentType: 'image/png',
size,
id: username,
id: sanitizedId,
},
];
}

type ImageRouteProps = { id: string };
type ImageRouteProps = { id: string; params: { username: string } };

export default async function OpenGraphImage(props: ImageRouteProps) {
let username = props.id;
// Decode emoji
let username = decodeURIComponent(props.params.username);

if (
username &&
Expand Down

0 comments on commit 8b26996

Please sign in to comment.