Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a6e0673

Browse filesBrowse 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 <benjamingr@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
1 parent 929ca30 commit a6e0673
Copy full SHA for a6e0673

File tree

Expand file treeCollapse file tree

1 file changed

+11
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-7
lines changed
Open diff view settings
Collapse file

‎doc/api/path.md‎

Copy file name to clipboardExpand all lines: doc/api/path.md
+11-7Lines changed: 11 additions & 7 deletions
  • Display the source diff
  • Display the rich diff
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.