From a6e06738ef7acb4528f6461f6447fec0f9699f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Mon, 3 Apr 2017 13:02:12 +0200 Subject: [PATCH] doc: path functions ignore trailing slashes Add notes about path.parse(), path.basename() and path.dirname() ignoring trailing slashes. PR-URL: https://github.com/nodejs/node/pull/12181 Fixes: https://github.com/nodejs/node/issues/6229 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Refael Ackermann Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Sam Roberts --- doc/api/path.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/doc/api/path.md b/doc/api/path.md index df65616b6c4e94..0c78c916497f6c 100644 --- a/doc/api/path.md +++ b/doc/api/path.md @@ -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: @@ -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: @@ -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: @@ -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