Skip to content

Commit 6c1825f

Browse files
committed
escape all risky characters of the fapi url
1 parent 9241825 commit 6c1825f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/testing/src/playwright/setupClerkTestingToken.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ export const setupClerkTestingToken = async ({ context, options, page }: SetupCl
3838
if (!fapiUrl) {
3939
throw new Error(ERROR_MISSING_FRONTEND_API_URL);
4040
}
41-
const apiUrl = new RegExp(`^https://${fapiUrl.replace(/\./g, '\\.')}/v1/.*?(\\?.*)?$`);
41+
42+
const escapedFapiUrl = fapiUrl.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
43+
const apiUrl = new RegExp(`^https://${escapedFapiUrl}/v1/.*?(\\?.*)?$`);
4244

4345
await browserContext.route(apiUrl, async route => {
4446
const originalUrl = new URL(route.request().url());

0 commit comments

Comments
 (0)