Skip to content

Commit

Permalink
Don't normalize path in PATH.basename() (#23180)
Browse files Browse the repository at this point in the history
This brings it in line with the behavior of basename im coreutils and
node.
  • Loading branch information
hoodmane authored Dec 17, 2024
1 parent 916b34e commit 0f4d8b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ See docs/process.md for more on how version tagging works.

3.1.75 (in development)
-----------------------
- `PATH.basename()` no longer calls `PATH.normalize()`, so that
`PATH.basename("a/.")` returns `"."` instead of `"a"` and
`PATH.basename("a/b/..")` returns `".."` instead of `"a"`. This is in line with
the behaviour of both node and coreutils, and is already the case when using
NODERAWFS". (#23180)

3.1.74 - 12/14/24
-----------------
Expand Down
5 changes: 2 additions & 3 deletions src/library_path.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ addToLibrary({
return root + dir;
},
basename: (path) => {
// EMSCRIPTEN return '/'' for '/', not an empty string
// EMSCRIPTEN return '/' for '/', not an empty string
if (path === '/') return '/';
path = PATH.normalize(path);
path = path.replace(/\/$/, "");
path = path.replace(/\/+$/g, "");
var lastSlash = path.lastIndexOf('/');
if (lastSlash === -1) return path;
return path.substr(lastSlash+1);
Expand Down

0 comments on commit 0f4d8b8

Please sign in to comment.