@@ -99,6 +99,28 @@ describe('redirect(redirectAdapter)', () => {
9999 ) ;
100100 } ) ;
101101
102+ it ( 'removes __clerk_synced when cross-origin redirect' , ( ) => {
103+ const returnBackUrl = 'https://current.url:3000/path?__clerk_synced=true&q=1#hash' ;
104+ const encodedUrl = 'https%3A%2F%2Fcurrent.url%3A3000%2Fpath%3Fq%3D1%23hash' ;
105+ const signUpUrl = 'https://lcl.dev/sign-up' ;
106+
107+ const redirectAdapterSpy = vi . fn ( ) . mockImplementation ( _url => 'redirectAdapterValue' ) ;
108+ const { redirectToSignUp } = createRedirect ( {
109+ baseUrl : 'http://www.clerk.com' ,
110+ devBrowserToken : 'deadbeef' ,
111+ redirectAdapter : redirectAdapterSpy ,
112+ publishableKey : 'pk_test_Y2xlcmsubGNsLmRldiQ' ,
113+ sessionStatus : 'active' ,
114+ signUpUrl,
115+ } ) ;
116+
117+ const result = redirectToSignUp ( { returnBackUrl } ) ;
118+ expect ( result ) . toBe ( 'redirectAdapterValue' ) ;
119+ expect ( redirectAdapterSpy ) . toHaveBeenCalledWith (
120+ `${ signUpUrl } ?redirect_url=${ encodedUrl } &__clerk_db_jwt=deadbeef` ,
121+ ) ;
122+ } ) ;
123+
102124 it ( 'returns path based url with development (kima) publishableKey (with staging Clerk) but without signUpUrl to redirectToSignUp' , ( ) => {
103125 const redirectAdapterSpy = vi . fn ( ) . mockImplementation ( _url => 'redirectAdapterValue' ) ;
104126 const { redirectToSignUp } = createRedirect ( {
@@ -320,5 +342,25 @@ describe('redirect(redirectAdapter)', () => {
320342 `https://included.katydid-92.accounts.dev/sign-up/tasks?redirect_url=${ encodedUrl } &__clerk_db_jwt=deadbeef` ,
321343 ) ;
322344 } ) ;
345+
346+ it ( 'removes __clerk_synced when cross-origin redirect' , ( ) => {
347+ const returnBackUrl = 'https://current.url:3000/path?__clerk_synced=true&q=1#hash' ;
348+ const encodedUrl = 'https%3A%2F%2Fcurrent.url%3A3000%2Fpath%3Fq%3D1%23hash' ;
349+
350+ const redirectAdapterSpy = vi . fn ( ) . mockImplementation ( _url => 'redirectAdapterValue' ) ;
351+ const { redirectToSignUp } = createRedirect ( {
352+ baseUrl : 'http://www.clerk.com' ,
353+ devBrowserToken : 'deadbeef' ,
354+ redirectAdapter : redirectAdapterSpy ,
355+ publishableKey : 'pk_test_Y2xlcmsubGNsLmRldiQ' ,
356+ sessionStatus : 'pending' ,
357+ } ) ;
358+
359+ const result = redirectToSignUp ( { returnBackUrl } ) ;
360+ expect ( result ) . toBe ( 'redirectAdapterValue' ) ;
361+ expect ( redirectAdapterSpy ) . toHaveBeenCalledWith (
362+ `https://accounts.lcl.dev/sign-up/tasks?redirect_url=${ encodedUrl } &__clerk_db_jwt=deadbeef` ,
363+ ) ;
364+ } ) ;
323365 } ) ;
324366} ) ;
0 commit comments