Skip to content

Commit abb6301

Browse files
committed
Clean amp; prefixes from search parameters in og/profile.tsx to resolve URL encoding issues; add debug
1 parent 3eecb06 commit abb6301

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

web/pages/api/og/profile.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function capitalize(str: string) {
2222
}
2323

2424
function OgProfile(props: ogProps) {
25+
console.log(props)
2526
const {avatarUrl, name, city, country, age, interests, keywords} = props
2627
let headline = props.headline
2728

@@ -167,7 +168,13 @@ export default async function handler(req: NextRequest) {
167168
try {
168169
const {searchParams} = new URL(req.url)
169170
const options = await getCardOptions()
170-
const ogProps = Object.fromEntries(searchParams.entries()) as ogProps
171+
172+
// Clean search params by removing 'amp;' prefixes that occur due to URL encoding
173+
const cleanedEntries = Array.from(searchParams.entries()).map(([key, value]) => [
174+
key.replace(/^amp;/, ''),
175+
value,
176+
])
177+
const ogProps = Object.fromEntries(cleanedEntries) as ogProps
171178
const image = OgProfile(ogProps)
172179

173180
return new ImageResponse(classToTw(image), options as ImageResponseOptions)

0 commit comments

Comments
 (0)