Skip to content

Commit 1b766bb

Browse files
fix(analytics): DATA-13050 Generate text correctly when product name has number sign in name
1 parent 2cd4478 commit 1b766bb

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/app/api/app/load/route.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ const jwtSchema = z.object({
3030
});
3131

3232
export async function GET(request: NextRequest) {
33-
function appendExchangeToken(url: string, token: string): string {
34-
const delimiter = new URL(url, env.APP_ORIGIN).search ? '&' : '?';
35-
36-
return `${url}${delimiter}exchangeToken=${token}`;
37-
}
38-
3933
const parsedParams = queryParamSchema.safeParse(
4034
Object.fromEntries(request.nextUrl.searchParams)
4135
);
@@ -64,8 +58,10 @@ export async function GET(request: NextRequest) {
6458
});
6559

6660
const exchangeToken = await db.saveClientToken(clientToken);
61+
const redirectUrl = new URL(path, env.APP_ORIGIN);
62+
redirectUrl.searchParams.set('exchangeToken', exchangeToken);
6763

68-
return NextResponse.redirect(new URL(appendExchangeToken(path, exchangeToken), env.APP_ORIGIN), {
64+
return NextResponse.redirect(redirectUrl, {
6965
status: 302,
7066
statusText: 'Found',
7167
});

src/app/productDescription/[productId]/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ import { headers } from 'next/headers';
66

77
interface PageProps {
88
params: { productId: string };
9-
searchParams: { product_name: string; exchangeToken: string };
9+
searchParams: { product_name?: string; exchangeToken?: string };
1010
}
1111

1212
export default async function Page(props: PageProps) {
1313
const { productId } = props.params;
1414
const { product_name: name, exchangeToken } = props.searchParams;
1515

16+
if (!exchangeToken) {
17+
throw new Error('Missing exchange token. Try to re-open the app.');
18+
}
19+
1620
const authToken = await db.getClientTokenMaybeAndDelete(exchangeToken) || 'missing';
1721

1822
const authorized = authorize(authToken);

0 commit comments

Comments
 (0)