11import { describe , expect , it } from 'vitest' ;
22
3- import { patchRequest } from '../server/utils ' ;
3+ import { patchRequest } from '../patchRequest ' ;
44
55describe ( 'patchRequest' , ( ) => {
66 it ( 'preserves the URL including path and query string' , ( ) => {
@@ -10,9 +10,6 @@ describe('patchRequest', () => {
1010 } ) ;
1111
1212 it ( 'preserves an encoded nested redirect_url with its own query and port' , ( ) => {
13- // Mirrors the shape reported in the TanStack + Lovable handshake bug:
14- // the outer URL's `redirect_url` param is a percent-encoded inner URL with
15- // a port and its own query string, which must survive the clone verbatim.
1613 const nested = 'https://localhost:8080/?token=abc' ;
1714 const original = new Request ( `https://example.com/handshake?redirect_url=${ encodeURIComponent ( nested ) } ` ) ;
1815 const cloned = patchRequest ( original ) ;
@@ -45,17 +42,7 @@ describe('patchRequest', () => {
4542 expect ( cloned . cache ) . toBe ( 'no-cache' ) ;
4643 } ) ;
4744
48- // The previous "forwards signal aborts" regression test cannot run under Node
49- // 24 + jsdom + undici: constructing `new Request(url, { signal })` with any
50- // AbortSignal throws TypeError due to undici's tightened cross-realm
51- // instanceof check. patchRequest intentionally omits the signal to avoid that
52- // error; verifying the trade-off in a unit test isn't possible in this
53- // environment.
54-
5545 it ( 'clones POST requests without forwarding the body' , ( ) => {
56- // patchRequest deliberately omits `body` from the cloned init (see #7020)
57- // so the original request's body stays intact for downstream consumers and
58- // the undici duplex issues the helper was written to avoid do not resurface.
5946 const original = new Request ( 'https://example.com/api' , {
6047 method : 'POST' ,
6148 body : 'payload' ,
@@ -64,5 +51,6 @@ describe('patchRequest', () => {
6451 const cloned = patchRequest ( original ) ;
6552 expect ( cloned . method ) . toBe ( 'POST' ) ;
6653 expect ( cloned . body ) . toBeNull ( ) ;
54+ expect ( original . bodyUsed ) . toBe ( false ) ;
6755 } ) ;
6856} ) ;
0 commit comments