From 6a45be2fa6a074d163aa2fa1e37ad5e4f54dc60d 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 afb44d2de0fa86..a6f1701261b3d1 100644 --- a/doc/api/path.md +++ b/doc/api/path.md @@ -68,7 +68,8 @@ changes: * 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: @@ -128,7 +129,8 @@ changes: * 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: @@ -347,7 +349,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: @@ -519,6 +522,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