-
Notifications
You must be signed in to change notification settings - Fork 17
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
Can't parse windows style absolute paths #19
Comments
I am interested in the following improvements:
I think there's a place for a function which can parse a Windows path into Pathy's structure, e.g. |
Thanks for your replies! Purely from a users perspective, I think it would be great if I could use pathy to parse paths the user gives me, manipulate them with pathy and then use the result with the purescript-node-fs functions to actually manipulate files and directories. Since a javascript node program will be used on both posix and windows environments, that would mean handling windows paths as well (e.g. if they are passed by the user as a command line argument). It is possible to get pretty far by parsing "C:\Users" into the internal representation /C/Users/ and then doing the reverse transform when converting back to a string on windows (just passing "/C/Users/" to the node runtime on windows does not work). One of the annoying details on windows is that volumes act as independent roots, i.e. unlike Posix paths there is no guarantee that you can create a relative path between two absolute paths on windows. The [node path api](#! https://nodejs.org/api/path.html) behaves different depending on the environment it is in which I think is a pretty undesirable trait - for one thing it makes platform independent testing difficult. I haven't really looked at the proposed code for version 2 of this library that will use Escapers, but I think the idea to be able to specify the behaviour with an Escaper and being able to get a default Escaper depending on the runtime environment would be a pretty nice way to deal with the problem. Do you think this is an idea worth pursuing? |
The only part I think doesn't belong in pathy is "get a default Escaper depending on the runtime environment". Currently, pathy is a 100% pure project, could be used by any backend, and advertises itself as being platform-independent. I think we would want to create side-projects like Seem reasonable? |
Yes, that sounds like a great solution. |
Noticed there still isn't a |
Yeah, a printer/parser for Windows still needs writing. I think treating the drive letter as the first part of the path, and just catching that in the printer and adding the colon as necessary would be an option there. It wouldn't support all windows paths, since there's the UNC |
it will have to parse |
I just naively tried to use this library under windows because it is advertised as "platform independent paths" and ran into trouble :). Currently, the library doesn't have an Escaper for windows directory seperators (backslash instead of forward slash) and can't parse absolute paths as used on the windows platform ("C:\Users").
There are more cases that would be nice to handle, most importantly network share paths ("\server\share\directory"), and some others that are more questionable (e.g. long path urls that start with "?").
Are you interested in extending this library to handle windows paths as well? If so I could try to write up a plan on how to add windows path support to purescript-pathy.
The text was updated successfully, but these errors were encountered: