From 93e4d545d8bfbab9730a5363d62bd63b57f3dd66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sat, 5 Sep 2020 12:46:57 +0200 Subject: [PATCH] doc: add note about path.basename on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/35065 Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen Reviewed-By: Gerhard Stöbich Reviewed-By: Rich Trott --- doc/api/path.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/api/path.md b/doc/api/path.md index caefc15e601f1a..3d94f15eea556e 100644 --- a/doc/api/path.md +++ b/doc/api/path.md @@ -87,6 +87,19 @@ path.basename('/foo/bar/baz/asdf/quux.html', '.html'); // Returns: 'quux' ``` +Although Windows usually treats file names, including file extensions, in a +case-insensitive manner, this function does not. For example, `C:\\foo.html` and +`C:\\foo.HTML` refer to the same file, but `basename` treats the extension as a +case-sensitive string: + +```js +path.win32.basename('C:\\foo.html', '.html'); +// Returns: 'foo' + +path.win32.basename('C:\\foo.HTML', '.html'); +// Returns: 'foo.HTML' +``` + A [`TypeError`][] is thrown if `path` is not a string or if `ext` is given and is not a string.