File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ test.describe('dev-default', () => {
2121 const f = useFixture ( { root : 'examples/basic' , mode : 'dev' } )
2222 defineTest ( f )
2323
24- test ( 'validate findSourceMapURL' , async ( ) => {
24+ test ( 'validate findSourceMapURL - reject ' , async ( ) => {
2525 const requestUrl = new URL ( f . url ( '__vite_rsc_findSourceMapURL' ) )
2626 requestUrl . searchParams . set (
2727 'filename' ,
@@ -31,6 +31,20 @@ test.describe('dev-default', () => {
3131 const response = await fetch ( requestUrl )
3232 expect ( response . status ) . toBe ( 404 )
3333 } )
34+
35+ test ( 'validate findSourceMapURL - pass' , async ( ) => {
36+ const requestUrl = new URL ( f . url ( '__vite_rsc_findSourceMapURL' ) )
37+ requestUrl . searchParams . set (
38+ 'filename' ,
39+ new URL ( '../examples/basic/package.json' , import . meta. url ) . href ,
40+ )
41+ requestUrl . searchParams . set ( 'environmentName' , 'Server' )
42+ const response = await fetch ( requestUrl )
43+ expect ( response . status ) . toBe ( 200 )
44+ expect ( await response . json ( ) ) . toMatchObject ( {
45+ version : 3 ,
46+ } )
47+ } )
3448} )
3549
3650test . describe ( 'dev-initial' , ( ) => {
Original file line number Diff line number Diff line change 66 type ViteDevServer ,
77} from 'vite'
88import fs from 'node:fs'
9+ import { slash } from './vite-utils'
910
1011//
1112// support findSourceMapURL
@@ -52,7 +53,7 @@ async function findSourceMapURL(
5253) : Promise < object | undefined > {
5354 // this is likely server external (i.e. outside of Vite processing)
5455 if ( filename . startsWith ( 'file://' ) ) {
55- filename = fileURLToPath ( filename )
56+ filename = slash ( fileURLToPath ( filename ) )
5657 if (
5758 isFileLoadingAllowed ( server . config , filename ) &&
5859 fs . existsSync ( filename )
You can’t perform that action at this time.
0 commit comments