hexo-util
hexo-util copied to clipboard
feat: joinPath()
ref: https://github.com/hexojs/hexo/pull/4479
this enhances path.join() to convert slash, but this joinPath() doesn't resolve '../' yet.
Coverage increased (+0.05%) to 97.476% when pulling c1295d6c77a58ecad58c897c1c32db2ea0e00ade on curbengh:join-path into bf42b664e717cbf81f338e8f67aad323797c336e on hexojs:master.
path.resolve() is work?
I mean this joinPath() doesn't support resolving path yet, perhaps in future if there is a demand, currently it's out of scope.
for now, need to joinPath(resolve(from, to), pathtwo).
fixed unit test, ready for review.
@curbengh
Recently I have found a package on npm: https://npm.im/url-join
Have a look?
See also https://github.com/hexojs/hexo/pull/5457
I believe there are many more pieces of code that could utilize this joinPath function.
I think it should be implemented based on path or any other module instead of string concatenation.
Yes, maybe path.posix.join will work for such cases.
Moreover, some other languages have more comprehensive libraries for path manipulation, rather than just simple string operations. I particularly like Rust's PathBuf, which is very elegant. I'm not sure if Node.js has a similar implementation.