@@ -4900,6 +4900,36 @@ test('init hook in-place mutations do not leak across requests', async t => {
49004900 t . deepEqual ( seenRequestIdentifiers , [ '1' , '2' ] ) ;
49014901} ) ;
49024902
4903+ test ( 'init hook tuple searchParams mutations do not leak across requests' , async t => {
4904+ let requestIdentifier = 0 ;
4905+ const seenInitialValues : string [ ] = [ ] ;
4906+ const seenRequestIdentifiers : string [ ] = [ ] ;
4907+
4908+ const api = ky . extend ( {
4909+ searchParams : [ [ 'requestId' , 'seed' ] ] ,
4910+ hooks : {
4911+ init : [
4912+ options => {
4913+ const searchParameters = options . searchParams as string [ ] [ ] ;
4914+ seenInitialValues . push ( searchParameters [ 0 ] ! [ 1 ] ! ) ;
4915+ searchParameters [ 0 ] ! [ 1 ] = String ( ++ requestIdentifier ) ;
4916+ } ,
4917+ ] ,
4918+ } ,
4919+ } ) ;
4920+
4921+ const fetch : typeof globalThis . fetch = async request => {
4922+ seenRequestIdentifiers . push ( new URL ( request . url ) . searchParams . get ( 'requestId' ) ! ) ;
4923+ return new Response ( 'ok' ) ;
4924+ } ;
4925+
4926+ await api . get ( 'https://example.com' , { fetch} ) ;
4927+ await api . get ( 'https://example.com' , { fetch} ) ;
4928+
4929+ t . deepEqual ( seenInitialValues , [ 'seed' , 'seed' ] ) ;
4930+ t . deepEqual ( seenRequestIdentifiers , [ '1' , '2' ] ) ;
4931+ } ) ;
4932+
49034933test ( 'init hook in-place retry mutations do not leak across requests' , async t => {
49044934 const seenLimits : number [ ] = [ ] ;
49054935
0 commit comments