Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
path: inline conditions
This condition can be inlined in the first `if` statement since if the `path`'s length is 0, it'll be a empty string so we can return that as there's no need for an extra `if` statement.
  • Loading branch information
VoltrexKeyva authored May 9, 2021
commit dee7116b2af0a8b165135b30f382ce23ce72548c
6 changes: 1 addition & 5 deletions lib/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,13 +617,9 @@ const win32 = {
*/
toNamespacedPath(path) {
// Note: this will *probably* throw somewhere.
if (typeof path !== 'string')
if (typeof path !== 'string' || path.length === 0)
return path;

if (path.length === 0) {
return '';
}

const resolvedPath = win32.resolve(path);

if (resolvedPath.length <= 2)
Expand Down