doc: add note about path.basename on Windows

PR-URL: https://github.com/nodejs/node/pull/35065
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Tobias Nießen authored and Ruy Adorno committed 2020-09-17 10:36:39 -04:00
1 parent 0a2610a7aa
commit 93e4d545d8
1 file changed
+13
+13
View File
@@ -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.