path.normalize()

path.normalize(p)

Normalize a string path, taking care of '..' and '.' parts.

When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.

Example:

path.normalize('/foo/bar//baz/asdf/quux/..')
// returns '/foo/bar/baz/asdf'

Note: If the path string passed as argument is a zero-length string then '.' will be returned, which represents the current working directory.

doc_Nodejs
2016-04-30 04:41:02
Comments
Leave a Comment

Please login to continue.