Windows and DOS all the time supported both directory delimiters. Number of places in Windows where forward slashes are not allowed is very small and should be considered buggy.
Current situation makes writing platform independent code extremely complex, in many cases integration tests of projects created by Unix guys just don't work on Windows (and vice versa).
Finally this separation brings more harm then good.
It would also fix https://github.com/nodejs/io.js/issues/616 - Path.relative would always return correct url separators.
I am not that naive, that I would expect this will be fixed, because it would probably break too many (probably mainly Windows) projects. But I would like to know view of node community about this problem.
I don't think it makes sense to change this. Using \
on Windows is more correct IMO. And, there is undoubtedly a ton of code in the ecosystem that relies on the existing behavior.
You can use the path.posix
namespace on every platform to use /
instead of the platform-dependent slash.
@mscdex It is not bad idea. In some cases it is really used everywhere in project - every npm module, so in that case would you advice to monkey patch require or there is better way?
@Bobris Well, probably adding url.relative()
would be better and having module authors use that instead of path.relative()
. If url.relative()
doesn't get added for some reason, then authors should probably use path.posix.relative()
. However that obviously won't work for node v0.10 if people care about that.
What would this make better that justifies potential ecosystem breakage?
Closing, The ecosystem is already quite heavily built on this. :s
Most helpful comment
You can use the
path.posix
namespace on every platform to use/
instead of the platform-dependent slash.