Skip to content

Commit be4b3a4

Browse files
VoltrexKeyvatargos
authored andcommitted
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. 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]>
1 parent b0df28d commit be4b3a4

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

lib/path.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -617,13 +617,9 @@ const win32 = {
617617
*/
618618
toNamespacedPath(path) {
619619
// Note: this will *probably* throw somewhere.
620-
if (typeof path !== 'string')
620+
if (typeof path !== 'string' || path.length === 0)
621621
return path;
622622

623-
if (path.length === 0) {
624-
return '';
625-
}
626-
627623
const resolvedPath = win32.resolve(path);
628624

629625
if (resolvedPath.length <= 2)

0 commit comments

Comments
 (0)