@@ -65,20 +65,34 @@ async function openProfile(profileJson: string) {
6565 const jsSource = `speedscope.loadFileFromBase64(${ JSON . stringify ( filename ) } , ${ JSON . stringify ( sourceBase64 ) } )`
6666
6767 const filePrefix = `speedscope-${ Number ( new Date ( ) ) } -${ process . pid } `
68- const jsPath = joinPath ( tempDirectory ( ) , `${ filePrefix } .js` )
68+ let jsPath = joinPath ( tempDirectory ( ) , `${ filePrefix } .js` )
6969 outputDebug ( `[Theme Profile] writing JS file to: ${ jsPath } ` )
7070 await writeFile ( jsPath , jsSource )
7171 outputDebug ( `[Theme Profile] JS file created successfully: ${ jsPath } ` )
72- urlToOpen += `#localProfilePath=${ jsPath } `
72+
73+ // WSL path conversion
74+ const distroName = process . env . WSL_DISTRO_NAME
75+ const wslPrefix = distroName ? `//wsl$/${ distroName } ` : ''
76+
77+ if ( distroName ) {
78+ outputDebug ( `[Theme Profile] WSL detected (${ distroName } )` )
79+ }
80+
81+ urlToOpen = `${ wslPrefix } ${ urlToOpen } `
82+ jsPath = `${ wslPrefix } ${ jsPath } `
7383
7484 // For some silly reason, the OS X open command ignores any query parameters or hash parameters
7585 // passed as part of the URL. To get around this weird issue, we'll create a local HTML file
7686 // that just redirects.
77- const htmlPath = joinPath ( tempDirectory ( ) , `${ filePrefix } .html` )
87+ urlToOpen += `#localProfilePath=${ jsPath } `
88+
89+ let htmlPath = joinPath ( tempDirectory ( ) , `${ filePrefix } .html` )
7890 outputDebug ( `[Theme Profile] writing HTML file to: ${ htmlPath } ` )
7991 await writeFile ( htmlPath , `<script>window.location=${ JSON . stringify ( urlToOpen ) } </script>` )
8092 outputDebug ( `[Theme Profile] HTML file created successfully: ${ htmlPath } ` )
8193
94+ htmlPath = `${ wslPrefix } ${ htmlPath } `
95+
8296 urlToOpen = `file://${ htmlPath } `
8397 outputDebug ( `[Theme Profile] Opening URL: ${ urlToOpen } ` )
8498 const opened = await openURL ( urlToOpen )
0 commit comments