Skip to content

Commit 04fb9e2

Browse files
authored
fix(testing): Update FAPI URL to use Regex on Playwright (#7036)
1 parent 8ebbf1e commit 04fb9e2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/cool-keys-scream.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/testing': patch
3+
---
4+
5+
Fix Playwright route URL to use RegExp instead of Glob URL pattern

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 = `https://${fapiUrl}/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)