Skip to content

Commit 6a45be2

Browse files
tniessenevanlucas
authored andcommitted
doc: path functions ignore trailing slashes
Add notes about path.parse(), path.basename() and path.dirname() ignoring trailing slashes. PR-URL: #12181 Fixes: #6229 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
1 parent 0661fdf commit 6a45be2

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

doc/api/path.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ changes:
6868
* Returns: {string}
6969

7070
The `path.basename()` methods returns the last portion of a `path`, similar to
71-
the Unix `basename` command.
71+
the Unix `basename` command. Trailing directory separators are ignored, see
72+
[`path.sep`][].
7273

7374
For example:
7475

@@ -128,7 +129,8 @@ changes:
128129
* Returns: {string}
129130

130131
The `path.dirname()` method returns the directory name of a `path`, similar to
131-
the Unix `dirname` command.
132+
the Unix `dirname` command. Trailing directory separators are ignored, see
133+
[`path.sep`][].
132134

133135
For example:
134136

@@ -347,7 +349,8 @@ added: v0.11.15
347349
* Returns: {Object}
348350

349351
The `path.parse()` method returns an object whose properties represent
350-
significant elements of the `path`.
352+
significant elements of the `path`. Trailing directory separators are ignored,
353+
see [`path.sep`][].
351354

352355
The returned object will have the following properties:
353356

@@ -519,6 +522,10 @@ On Windows:
519522
// Returns: ['foo', 'bar', 'baz']
520523
```
521524

525+
*Note*: On Windows, both the forward slash (`/`) and backward slash (`\`) are
526+
accepted as path segment separators; however, the `path` methods only add
527+
backward slashes (`\`).
528+
522529
## path.win32
523530
<!-- YAML
524531
added: v0.11.15
@@ -529,11 +536,8 @@ added: v0.11.15
529536
The `path.win32` property provides access to Windows-specific implementations
530537
of the `path` methods.
531538

532-
*Note*: On Windows, both the forward slash (`/`) and backward slash (`\`)
533-
characters are accepted as path delimiters; however, only the backward slash
534-
(`\`) will be used in return values.
535-
536539
[`path.posix`]: #path_path_posix
540+
[`path.sep`]: #path_path_sep
537541
[`path.win32`]: #path_path_win32
538542
[`path.parse()`]: #path_path_parse_path
539543
[`TypeError`]: errors.html#errors_class_typeerror

0 commit comments

Comments
 (0)