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 <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>
  • Loading branch information
tniessen authored and ruyadorno committed Sep 17, 2020
1 parent 0a2610a commit 93e4d54
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 93e4d54

Please sign in to comment.