Skip to content

Commit

Permalink
doc: path functions ignore trailing slashes
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
tniessen authored and MylesBorins committed May 18, 2017
1 parent 929ca30 commit a6e0673
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions doc/api/path.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ added: v0.1.25
* Returns: {String}

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

For example:

Expand Down Expand Up @@ -120,7 +121,8 @@ added: v0.1.16
* Returns: {String}

The `path.dirname()` method returns the directory name of a `path`, similar to
the Unix `dirname` command.
the Unix `dirname` command. Trailing directory separators are ignored, see
[`path.sep`][].

For example:

Expand Down Expand Up @@ -335,7 +337,8 @@ added: v0.11.15
* Returns: {Object}

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

The returned object will have the following properties:

Expand Down Expand Up @@ -506,6 +509,10 @@ On Windows:
// Returns: ['foo', 'bar', 'baz']
```

*Note*: On Windows, both the forward slash (`/`) and backward slash (`\`) are
accepted as path segment separators; however, the `path` methods only add
backward slashes (`\`).

## path.win32
<!-- YAML
added: v0.11.15
Expand All @@ -516,11 +523,8 @@ added: v0.11.15
The `path.win32` property provides access to Windows-specific implementations
of the `path` methods.

*Note*: On Windows, both the forward slash (`/`) and backward slash (`\`)
characters are accepted as path delimiters; however, only the backward slash
(`\`) will be used in return values.

[`path.posix`]: #path_path_posix
[`path.sep`]: #path_path_sep
[`path.win32`]: #path_path_win32
[`path.parse()`]: #path_path_parse_path
[`TypeError`]: errors.html#errors_class_typeerror

0 comments on commit a6e0673

Please sign in to comment.