-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
docs: explain why path.posix.normalize does not replace windows slashes #12298
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
If I get this right, const path = require('path');
const win32ToPosix = '\\win32\\to\\posix';
const posixToWin32 = '/posix/to/win32';
console.log(`
${path.posix.basename(win32ToPosix)}
${path.win32.basename(posixToWin32)}
${path.posix.dirname(win32ToPosix)}
${path.win32.dirname(posixToWin32)}
${path.posix.normalize(win32ToPosix)}
${path.win32.normalize(posixToWin32)}
${JSON.stringify(path.posix.parse(win32ToPosix))}
${JSON.stringify(path.win32.parse(posixToWin32))}
${path.posix.resolve(win32ToPosix)}
${path.win32.resolve(posixToWin32)}
`);
|
Answered. Closing, working as intended. |
the docs say:
which is a little weird so I skimmed it with my understanding, but for postarity this this doesn't work either: console.log('1', path.posix.normalize("\\\\some\\\\thing\\\\like\\\\this"))
console.log('2', path.posix.normalize("/\\some/\\thing/\\like/\\this")) To be fair it is vague enough to have concluded to my understanding... but on a more conceptual/abstract/module angle a conversion looking like this is intended / not available in a path manipulation library or am I missing something? path.normalize(file).split(/[\\\/]/g).join(path.posix.sep) |
@Seudein On POSIX, |
Maybe we need a |
@refack Sorry, could you explain how those methods would behave? |
I think what @Seudein assumed was that using
@bnoordhuis I believe that if a user open an issue based on wrong assumptions that are not addressed in the docs, it should be treated as a bug in the docs. |
Reopened as a |
|
I agree. Super important! |
Add section to path docs that explains that path.posix.normalize does not replace Windows slashes with POSIX slashes because POSIX does not recognize / as a valid path separator. Fixes: #12298 PR-URL: #12700 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Cai <davidcai1993@yahoo.com>
Add section to path docs that explains that path.posix.normalize does not replace Windows slashes with POSIX slashes because POSIX does not recognize / as a valid path separator. Fixes: nodejs#12298 PR-URL: nodejs#12700 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Cai <davidcai1993@yahoo.com>
Add section to path docs that explains that path.posix.normalize does not replace Windows slashes with POSIX slashes because POSIX does not recognize / as a valid path separator. Fixes: #12298 PR-URL: #12700 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Cai <davidcai1993@yahoo.com>
Add section to path docs that explains that path.posix.normalize does not replace Windows slashes with POSIX slashes because POSIX does not recognize / as a valid path separator. Fixes: #12298 PR-URL: #12700 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Cai <davidcai1993@yahoo.com>
output:

1 output should be the same as 2s thoughDocs need to explain why this is the expected output
The text was updated successfully, but these errors were encountered: