diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-10-28 14:51:32 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-10-28 14:51:32 -0700 |
commit | b98b583f93c557ff3396cf1cc13146f9f878a9b0 (patch) | |
tree | 485bc391af1e504641b675185b05518cb6b5d6b4 /src/library_path.js | |
parent | 24a2894d567469a1c44430b4c6f43b5bbec41821 (diff) |
optimize PATH.basename
Diffstat (limited to 'src/library_path.js')
-rw-r--r-- | src/library_path.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/library_path.js b/src/library_path.js index 01476e8d..f00a7586 100644 --- a/src/library_path.js +++ b/src/library_path.js @@ -62,7 +62,9 @@ mergeInto(LibraryManager.library, { basename: function(path) { // EMSCRIPTEN return '/'' for '/', not an empty string if (path === '/') return '/'; - return PATH.splitPath(path)[2]; + var lastSlash = path.lastIndexOf('/'); + if (lastSlash === -1) return path; + return path.substr(lastSlash+1); }, extname: function(path) { return PATH.splitPath(path)[3]; |