Skip to content

Commit 3954b8f

Browse files
tniessenaddaleax
authored andcommitted
doc: add note about path.basename on Windows
PR-URL: #35065 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent d60c487 commit 3954b8f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

doc/api/path.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ path.basename('/foo/bar/baz/asdf/quux.html', '.html');
8787
// Returns: 'quux'
8888
```
8989

90+
Although Windows usually treats file names, including file extensions, in a
91+
case-insensitive manner, this function does not. For example, `C:\\foo.html` and
92+
`C:\\foo.HTML` refer to the same file, but `basename` treats the extension as a
93+
case-sensitive string:
94+
95+
```js
96+
path.win32.basename('C:\\foo.html', '.html');
97+
// Returns: 'foo'
98+
99+
path.win32.basename('C:\\foo.HTML', '.html');
100+
// Returns: 'foo.HTML'
101+
```
102+
90103
A [`TypeError`][] is thrown if `path` is not a string or if `ext` is given
91104
and is not a string.
92105

0 commit comments

Comments
 (0)