Article From:

Only enter the pit, Xiao Bai

 path.join('foo/', 'baz/', '../bar'); // => "foo/bar"

Why do you ignore Baz /?
It’s the same level after Baz / up level, so the default use is later.

path.dirname('/foo/bar/baz/asdf/quux');// Returns: '/foo/bar/baz/asdf'

Why do you ignore quux? Is the default quux file?

Answer 0:

path.join('foo/', 'baz/', '../bar') The result of direct stitching isfoo/baz/../bar,After the reduction isfoo/bar,The same position is pointed before and after the reduction, but obviously this is more succinct.

path.dirname The last section of the path is removed directly, and the document mentions that if it ends with a directory separator, the separator is ignored.

Link of this Article: Nodejs path API problem

Leave a Reply

Your email address will not be published. Required fields are marked *