Skip to content

Commit

Permalink
path: inline conditions
Browse files Browse the repository at this point in the history
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.

PR-URL: #38613
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
VoltrexKeyva authored and targos committed May 17, 2021
1 parent b0df28d commit be4b3a4
Showing 1 changed file with 1 addition and 5 deletions.
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

0 comments on commit be4b3a4

Please sign in to comment.