Decode URL pathname for opened file (#11118)

- Attempt to fix an issue where a project opened by double clicking does not URL decode the path to be opened.
- Unable to properly test as I don't normally use Windows (file associations do not work on Linux as we use an AppImage for that platform.)

# Important Notes
None
This commit is contained in:
somebody1234 2024-09-18 19:51:11 +10:00 committed by GitHub
parent 38685dafa9
commit 9126ab23e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -106,10 +106,12 @@ function fileURLToPath(url: string): string | null {
if (URL.canParse(url)) {
const parsed = new URL(url)
if (parsed.protocol === 'file:') {
return detect.platform() === detect.Platform.windows ?
return decodeURIComponent(
detect.platform() === detect.Platform.windows ?
// On Windows, we must remove leading `/` from URL.
parsed.pathname.slice(1)
: parsed.pathname
: parsed.pathname,
)
} else {
return null
}