yyx990803 / launch-editor

Open file in editor from Node.js.
MIT License
585 stars 67 forks source link

fix: update regex to allow whitespace & `+` in Windows path #74

Closed MauriceChocoSwiss closed 3 months ago

MauriceChocoSwiss commented 3 months ago

Updated regex to authorize whitespace in file path.

Many projects has a whitespace in folder name (like me). Many time it doesn't affect anything but here it prevent file to open.

Let me know !

dominikg commented 3 months ago

Hey,

would you be interested in adding + as well? Thats used by sveltekit ( see https://github.com/yyx990803/launch-editor/issues/50#issuecomment-2227992963 ) and https://github.com/sveltejs/vite-plugin-svelte/issues/943

cc @sodatea this would be the "expand allow list" i mentioned, might be a stop-gap solution until you find the time to implement propper escaping.

MauriceChocoSwiss commented 3 months ago

Why not, I didn't use sveltkit but I think it can be good for sveltkit user.

dominikg commented 3 months ago

i wonder if you want \s or an actual space char in that group

MauriceChocoSwiss commented 3 months ago

I prefer to use the \s, it cover more cases like tabs, line breaks etc... In case of ^^

dominikg commented 3 months ago

is it possible to have line breaks or tabs in a file path on windows? (that file system never fails to impress, just not sure if in a positive way)

MauriceChocoSwiss commented 3 months ago

I really don't know... You prefer to use only spaces ?

dominikg commented 3 months ago

unless they are possible/allowed, i would prefer just space, but maybe @sodatea has a different opinion.

It would be good to get this merged soonish so we can include it in vite 5.5.

haoqunjiang commented 3 months ago

According to https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file CR, LF and TABs are not allowed in a file path. So I think a single space character should suffice.

haoqunjiang commented 3 months ago

As for other special characters, there seem to be many more to add for compatibility with all the popular filesystem-based routing solutions, but I'll leave that to a later PR.

oneezy commented 2 months ago

As for other special characters, there seem to be many more to add for compatibility with all the popular filesystem-based routing solutions, but I'll leave that to a later PR.

yeahh @sodatea it's still an issue on Win11

Reference

issue: https://github.com/sveltejs/vite-plugin-svelte/issues/943#issuecomment-2308578599

Loizzus commented 2 months ago

I don't think banning characters is the solution to this problem. Even if you did find all the characters that are currently used by every system that depends on Vite why prevent some creative new use of valid special characters in the future? This entire feature seems very short sighted.