-
Notifications
You must be signed in to change notification settings - Fork 7.3k
path.split() needed, as counterpart to path.join() #1224
Comments
The tricky bit is that windows paths are more like urls than posix paths. For instance, @piscisaureus We'd talked way back when about having some kind of @aseemk Would that meet your needs? You could also just split on |
Man, a That said, even after parsing a (possibly Windows) filepath to split the device (drive) and the rest of the path, it's still common to need to split the path portion into directories, so a Yep, I can hardcode the slashes myself and check for Windows; just commenting though that, IMHO, Node as a framework should abstract that away so that every developer doesn't have to do that themselves. |
Btw, I was also thinking of filing a feature request for some method that tells me whether a given path is absolute or relative. On UNIX, checking it is easy -- just see if it begins with '/' -- but again, it seems like Node should abstract that away both for robustness (cross-platform) and convenience. It'd be great if a hypothetical |
I agree that functionality like path.parse/path.split can be useful. However there is some danger that people will abuse it to implement their own path.resolve in a crappy way. Also, don't be tempted to think that the concept of "absolute" and "relative" is somehow portable. |
@isaacs: is this still on the map? The functionality is mostly there in lib/path.js, it's just not exported. https://github.com/joyent/node/blob/master/lib/path.js#L66-79 |
@piscisaureus Yeah, we should just export it and add some tests. It would mean that I don't have to implement it in npm in a crappy way :) |
Is this still okay to get this exported?? I can try to get a pull request together and some tests. |
just googled for |
|
@OrangeDog thanks! |
This has been implemented by #7429. |
Fixed in 2d17193. |
I know this is old, but... that change implements |
Landed here looking for a path.split as well. I agree with @callumlocke, this probably shouldn't have been closed with path.parse(). |
I have a path like "/Users/aseemk/Projects/Foo", and I'd like to break it apart into components. There needs to be a standard
path.split()
for me to do so; splitting on '/' won't be portable to Windows.The text was updated successfully, but these errors were encountered: