@@ -2344,6 +2344,46 @@ if (getAvailableFeatures().has("binary-over-http")) {
23442344 fetchConn . rawParse ( Language . EDGEQL , `select 1` , Options . defaults ( ) ) ,
23452345 ) . rejects . toThrow ( AuthenticationError ) ;
23462346 } ) ;
2347+
2348+ test ( "getAuthenticatedFetch encodes database path segment" , async ( ) => {
2349+ const originalFetch = globalThis . fetch ;
2350+
2351+ const fetchMock = jest . fn ( async ( ) =>
2352+ ( {
2353+ ok : true ,
2354+ status : 200 ,
2355+ statusText : "OK" ,
2356+ headers : new Headers ( ) ,
2357+ arrayBuffer : async ( ) => new ArrayBuffer ( 0 ) ,
2358+ } ) as any ,
2359+ ) ;
2360+
2361+ ( globalThis as any ) . fetch = fetchMock ;
2362+
2363+ const config = {
2364+ address : [ "localhost" , 5656 ] ,
2365+ tlsSecurity : "insecure" ,
2366+ database : "preview/pr-662" ,
2367+ secretKey : "test-secret" ,
2368+ user : "test-user" ,
2369+ } as any ;
2370+
2371+ const authenticatedFetch = await getAuthenticatedFetch (
2372+ config ,
2373+ async ( ) => "token" ,
2374+ ) ;
2375+
2376+ await authenticatedFetch ( "" , { } ) ;
2377+
2378+ expect ( fetchMock ) . toHaveBeenCalledTimes ( 1 ) ;
2379+
2380+ const [ urlArg ] = fetchMock . mock . calls [ 0 ] ;
2381+ const url = typeof urlArg === "string" ? new URL ( urlArg ) : urlArg ;
2382+
2383+ expect ( url . pathname ) . toBe ( "/db/preview%2Fpr-662/" ) ;
2384+
2385+ ( globalThis as any ) . fetch = originalFetch ;
2386+ } ) ;
23472387}
23482388
23492389if ( getGelVersion ( ) . major >= 5 ) {
0 commit comments