Skip to content

Commit a6e0673

Browse files
tniessenMylesBorins
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 929ca30 commit a6e0673

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
@@ -64,7 +64,8 @@ added: v0.1.25
6464
* Returns: {String}
6565

6666
The `path.basename()` methods returns the last portion of a `path`, similar to
67-
the Unix `basename` command.
67+
the Unix `basename` command. Trailing directory separators are ignored, see
68+
[`path.sep`][].
6869

6970
For example:
7071

@@ -120,7 +121,8 @@ added: v0.1.16
120121
* Returns: {String}
121122

122123
The `path.dirname()` method returns the directory name of a `path`, similar to
123-
the Unix `dirname` command.
124+
the Unix `dirname` command. Trailing directory separators are ignored, see
125+
[`path.sep`][].
124126

125127
For example:
126128

@@ -335,7 +337,8 @@ added: v0.11.15
335337
* Returns: {Object}
336338

337339
The `path.parse()` method returns an object whose properties represent
338-
significant elements of the `path`.
340+
significant elements of the `path`. Trailing directory separators are ignored,
341+
see [`path.sep`][].
339342

340343
The returned object will have the following properties:
341344

@@ -506,6 +509,10 @@ On Windows:
506509
// Returns: ['foo', 'bar', 'baz']
507510
```
508511

512+
*Note*: On Windows, both the forward slash (`/`) and backward slash (`\`) are
513+
accepted as path segment separators; however, the `path` methods only add
514+
backward slashes (`\`).
515+
509516
## path.win32
510517
<!-- YAML
511518
added: v0.11.15
@@ -516,11 +523,8 @@ added: v0.11.15
516523
The `path.win32` property provides access to Windows-specific implementations
517524
of the `path` methods.
518525

519-
*Note*: On Windows, both the forward slash (`/`) and backward slash (`\`)
520-
characters are accepted as path delimiters; however, only the backward slash
521-
(`\`) will be used in return values.
522-
523526
[`path.posix`]: #path_path_posix
527+
[`path.sep`]: #path_path_sep
524528
[`path.win32`]: #path_path_win32
525529
[`path.parse()`]: #path_path_parse_path
526530
[`TypeError`]: errors.html#errors_class_typeerror

0 commit comments

Comments
 (0)