Skip to content

Commit

Permalink
fix undefined errors
Browse files Browse the repository at this point in the history
  • Loading branch information
helios2003 committed Jul 9, 2024
1 parent 9703ac0 commit 20d5536
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion apps/studio-next/src/app/api/crawler/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,21 @@ export async function GET(request: NextRequest) {
if (!searchParams) return new NextResponse(null, { status: 200 });
const info: DocumentInfo = await parseURL(searchParams);

const ogImageurl = `https://ogp-studio.netlify.app/api/og?title=${encodeURIComponent(info.title!)}&description=${encodeURIComponent(info.description!)}&numServers=${info.numServers}&numChannels=${info.numChannels}`;
let ogImageParams = new URLSearchParams();

if (info.title !== undefined) {
ogImageParams.append('title', encodeURIComponent(info.title));
}
if (info.description !== undefined) {
ogImageParams.append('description', encodeURIComponent(info.description));
}
if (info.numServers !== undefined) {
ogImageParams.append('numServers', info.numServers.toString());
}
if (info.numChannels !== undefined) {
ogImageParams.append('numChannels', info.numChannels.toString());
}
const ogImageurl = `https://ogp-studio.netlify.app/api/og?${ogImageParams.toString()}`;

const crawlerInfo = `
<!DOCTYPE html>
Expand Down

0 comments on commit 20d5536

Please sign in to comment.