@@ -71,6 +71,7 @@ const startHttpFixture = (
7171 // String pattern with wildcards
7272 const pattern = regexRoute . url . replace ( / \* / g, '.*' ) ;
7373 const regex = new RegExp ( `^${ pattern } $` ) ;
74+
7475 if ( regex . test ( pathname ) || regex . test ( `http://${ address } ${ pathname } ` ) ) {
7576 route = {
7677 status : regexRoute . status || 200 ,
@@ -251,6 +252,7 @@ export const setupFetchMock = async (options: FetchMockSetup = {}): Promise<Fetc
251252
252253 // Start fixture server with regex routes for dynamic matching
253254 const fixtureOptions : StartHttpFixtureOptions = { routes : fixtureRoutes , address } ;
255+
254256 if ( port ) {
255257 fixtureOptions . port = port ;
256258 }
@@ -260,12 +262,15 @@ export const setupFetchMock = async (options: FetchMockSetup = {}): Promise<Fetc
260262 const matchRoute = ( url : string ) : FetchRoute | undefined => {
261263 // Extract pathname from URL for matching
262264 let pathname : string ;
265+
263266 try {
264267 const urlObj = new URL ( url ) ;
268+
265269 pathname = urlObj . pathname ;
266270 } catch {
267271 // If URL parsing fails, try to extract pathname manually
268272 const match = url . match ( / ^ h t t p s ? : \/ \/ [ ^ / ] + ( \/ .* ) $ / ) ;
273+
269274 pathname = match && match [ 1 ] ? match [ 1 ] : url ;
270275 }
271276
@@ -307,6 +312,7 @@ export const setupFetchMock = async (options: FetchMockSetup = {}): Promise<Fetc
307312 // For regex/pattern matches, extract the pathname from the matched URL
308313 try {
309314 const urlObj = new URL ( url ) ;
315+
310316 fixturePath = urlObj . pathname ;
311317 } catch {
312318 // If URL parsing fails, fall back to index-based path
@@ -318,6 +324,7 @@ export const setupFetchMock = async (options: FetchMockSetup = {}): Promise<Fetc
318324 // Note: This is important for stdio servers that run in separate processes
319325 // and make real HTTP requests to the fixture server
320326 const normalizedPath = fixturePath . startsWith ( '/' ) ? fixturePath : `/${ fixturePath } ` ;
327+
321328 if ( fixture . addRoute ) {
322329 // Check if route already exists to avoid overwriting
323330 if ( ! fixtureRoutes [ normalizedPath ] ) {
0 commit comments