File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed
packages/backend/src/tokens Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @clerk/backend " : patch
3+ ---
4+
5+ Fix error from duplicate leading slashes in URL path on Cloudflare Pages
Original file line number Diff line number Diff line change @@ -151,6 +151,14 @@ export default (QUnit: QUnit) => {
151151 } ) ;
152152 assert . equal ( createClerkRequest ( req ) . clerkUrl . toString ( ) , 'https://example.com/path?foo=bar' ) ;
153153 } ) ;
154+
155+ it ( 'with duplicate leading slashes in URL path' , assert => {
156+ const req1 = new Request ( 'http://localhost:3000//path' ) ;
157+ assert . equal ( createClerkRequest ( req1 ) . clerkUrl . toString ( ) , 'http://localhost:3000//path' ) ;
158+
159+ const req2 = new Request ( 'http://localhost:3000////path' ) ;
160+ assert . equal ( createClerkRequest ( req2 ) . clerkUrl . toString ( ) , 'http://localhost:3000////path' ) ;
161+ } ) ;
154162 } ) ;
155163
156164 module ( 'toJSON' , ( ) => {
Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ class ClerkRequest extends Request {
5151 const resolvedProtocol = this . getFirstValueFromHeader ( forwardedProto ) ?? protocol ?. replace ( / [: / ] / , '' ) ;
5252 const origin = resolvedHost && resolvedProtocol ? `${ resolvedProtocol } ://${ resolvedHost } ` : initialUrl . origin ;
5353
54+ if ( origin === initialUrl . origin ) {
55+ return createClerkUrl ( initialUrl ) ;
56+ }
5457 return createClerkUrl ( initialUrl . pathname + initialUrl . search , origin ) ;
5558 }
5659
You can’t perform that action at this time.
0 commit comments