Skip to content

Commit 7c731ec

Browse files
piscisaureusry
authored andcommitted
Path.resolve, path module windows compatibility
Removes path.normalizeArray() and path.split()
1 parent 48334dc commit 7c731ec

File tree

3 files changed

+304
-125
lines changed

3 files changed

+304
-125
lines changed

doc/api/path.markdown

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,60 @@
33
This module contains utilities for dealing with file paths. Use
44
`require('path')` to use it. It provides the following methods:
55

6+
### path.normalize(p)
7+
8+
Normalize a string path, taking care of `'..'` and `'.'` parts.
9+
10+
When multiple slashes are found, they're replaces by a single one;
11+
when the path contains a trailing slash, it is preserved.
12+
On windows backslashes are used.
13+
14+
Example:
15+
16+
path.normalize('/foo/bar//baz/asdf/quux/..')
17+
// returns
18+
'/foo/bar/baz/asdf'
19+
620
### path.join([path1], [path2], [...])
721

8-
Join all arguments together and resolve the resulting path.
22+
Join all arguments together and normalize the resulting path.
923

1024
Example:
1125

1226
node> require('path').join(
1327
... '/foo', 'bar', 'baz/asdf', 'quux', '..')
1428
'/foo/bar/baz/asdf'
1529

16-
### path.normalizeArray(arr)
30+
### path.resolve([from ...], to)
1731

18-
Normalize an array of path parts, taking care of `'..'` and `'.'` parts.
32+
Resolves `to` to an absolute path name and normalizes it.
1933

20-
Example:
34+
One ore more `from` arguments may be provided to specify the the starting
35+
point from where the path will be resolved. `resolve` will prepend `from`
36+
arguments from right to left until an absolute path is found. If no `from`
37+
arguments are specified, or after prepending them still no absolute path is
38+
found, the current working directory will be prepended eventually.
2139

22-
path.normalizeArray(['',
23-
'foo', 'bar', 'baz', 'asdf', 'quux', '..'])
24-
// returns
25-
[ '', 'foo', 'bar', 'baz', 'asdf' ]
40+
Trailing slashes are removed unless the path gets resolved to the root
41+
directory.
2642

27-
### path.normalize(p)
43+
Examples:
2844

29-
Normalize a string path, taking care of `'..'` and `'.'` parts.
45+
path.resolve('index.html')
46+
// returns
47+
'/home/tank/index.html'
3048

31-
Example:
49+
path.resolve('/foo/bar', './baz')
50+
// returns
51+
'/foo/baz/baz'
3252

33-
path.normalize('/foo/bar/baz/asdf/quux/..')
53+
path.resolve('/foo/bar', '/tmp/file/')
3454
// returns
35-
'/foo/bar/baz/asdf'
55+
'/tmp/file'
56+
57+
path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif')
58+
// returns
59+
'/home/tank/wwwroot/static_files/gif/image.gif'
3660

3761
### path.dirname(p)
3862

0 commit comments

Comments
 (0)