Skip to content

Commit

Permalink
doc: add note about path.basename on Windows
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
tniessen authored and addaleax committed Sep 22, 2020
1 parent d60c487 commit 3954b8f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions doc/api/path.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 3954b8f

Please sign in to comment.