@@ -32,6 +32,7 @@ import {
3232 isValidApiRequest ,
3333} from 'vitest/node'
3434import { WebSocketServer } from 'ws'
35+ import { slash } from './utils'
3536
3637const debug = createDebugger ( 'vitest:browser:api' )
3738
@@ -293,7 +294,7 @@ export function setupBrowserRpc(
293294 for ( const attachment of attachments ) {
294295 const path = attachment . path
295296 if ( path && ! path . startsWith ( 'http://' ) && ! path . startsWith ( 'https://' ) ) {
296- checkFileAccess ( resolve ( project . config . root , path ) )
297+ checkFileAccess ( resolve ( project . config . root , slash ( path ) ) )
297298 }
298299 }
299300 }
@@ -304,7 +305,7 @@ export function setupBrowserRpc(
304305 return vitest . _testRun . recordBenchmark ( testId , benchmark )
305306 } ,
306307 async readBenchmarkResult ( relativePath ) {
307- checkFileAccess ( project . benchmark . resolve ( relativePath ) )
308+ checkFileAccess ( project . benchmark . resolve ( slash ( relativePath ) ) )
308309 return project . benchmark . readResult ( relativePath )
309310 } ,
310311 async writeBenchmarkResult ( relativePath , data ) {
@@ -314,7 +315,7 @@ export function setupBrowserRpc(
314315 )
315316 return
316317 }
317- checkFileAccess ( project . benchmark . resolve ( relativePath ) )
318+ checkFileAccess ( project . benchmark . resolve ( slash ( relativePath ) ) )
318319 return project . benchmark . writeResult ( relativePath , data )
319320 } ,
320321 async onTaskUpdate ( method , packs , events ) {
@@ -479,8 +480,9 @@ export function setupBrowserRpc(
479480 } else {
480481 if ( module . type === 'redirect' ) {
481482 const redirectUrl = new URL ( module . redirect )
482- module . redirect = join ( vite . config . root , redirectUrl . pathname )
483- checkFileAccess ( module . redirect )
483+ const redirect = join ( vite . config . root , slash ( redirectUrl . pathname ) )
484+ checkFileAccess ( redirect )
485+ module . redirect = redirect
484486 }
485487 defaultMockerRegistry . register ( module )
486488 }
0 commit comments