Skip to content

fix: support file URIs for middleware#95

Merged
haoqunjiang merged 1 commit intoyyx990803:masterfrom
sapphi-red:fix/file-url-support-for-middleware
Jul 28, 2025
Merged

fix: support file URIs for middleware#95
haoqunjiang merged 1 commit intoyyx990803:masterfrom
sapphi-red:fix/file-url-support-for-middleware

Conversation

@sapphi-red
Copy link
Contributor

Since the file query was passed to path.resolve(srcRoot, file), file urls did not work when using launch-editor-middleware. This PR fixes that.

refs #53 #91

@haoqunjiang haoqunjiang merged commit 7beed42 into yyx990803:master Jul 28, 2025
@sapphi-red sapphi-red deleted the fix/file-url-support-for-middleware branch July 31, 2025 05:33
res.end(`launch-editor-middleware: required query param "file" is missing.`)
} else {
launch(path.resolve(srcRoot, file), specifiedEditor, onErrorCallback)
const resolved = file.startsWith('file://') ? file : path.resolve(srcRoot, file)
Copy link
Contributor

@dominikg dominikg Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be

const resolved = file.startsWith('file://') ? file : `file://${path.resolve(srcRoot, file)}`

(potentially needs special handling for drive letter on windows too)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

launch-editor supports normal paths, so it should be fine.

const parsed = parseFile(file)

if (file.startsWith('file://')) {
file = require('url').fileURLToPath(file)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants