Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support file: protocol #53

Open
sapphi-red opened this issue Dec 12, 2022 · 3 comments
Open

Support file: protocol #53

sapphi-red opened this issue Dec 12, 2022 · 3 comments

Comments

@sapphi-red
Copy link
Contributor

Currently file protocol (e.g. /__open-in-editor?file=file%3A%2F%2F%2FC%3A%2Ffoo.js:13:24) is not supported.

Because using fileURLToPath in browser requires a polyfill, I think it would be nice if file protocol is supported.

@Exponential-Workload
Copy link

afaik that is impossible; the file: protocol is handled by your browser, meaning you can't bind some node code to a file URL. you'd need to patch your browser, or patch your kernel's filesystem read operations

@sapphi-red
Copy link
Contributor Author

I'm not saying that launch-editor should intercept requests accessing to URLs with file: protocol which is impossible as you say.
I'm saying that I want launch-editor to support file URLs to be accepted as the first parameter.

import launch from 'launch-editor'
launch('file:///foo/bar/foo.js:12:34')

@Exponential-Workload
Copy link

ah i see - one way to implement this would be something like:

const toFsPath = (path:string) => (new URL(path,'file:///')).pathname;

which works with both file:///'s (ie toFsPath('file:///foo/bar/foo.js:12:34');) aswell as raw paths, like toFsPath('/foo/bar/foo:12:34');

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

No branches or pull requests

2 participants