diff --git a/ChangeLog.md b/ChangeLog.md index ffbe23ccb3f95..05d25fe02c842 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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 ----------------- diff --git a/src/library_path.js b/src/library_path.js index ab3112503a202..fd5fec3dc2c46 100644 --- a/src/library_path.js +++ b/src/library_path.js @@ -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);