Skip to content

Commit c738b73

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 <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent e64c247 commit c738b73

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
@@ -608,13 +608,9 @@ const win32 = {
608608

609609
toNamespacedPath(path) {
610610
// Note: this will *probably* throw somewhere.
611-
if (typeof path !== 'string')
611+
if (typeof path !== 'string' || path.length === 0)
612612
return path;
613613

614-
if (path.length === 0) {
615-
return '';
616-
}
617-
618614
const resolvedPath = win32.resolve(path);
619615

620616
if (resolvedPath.length <= 2)

0 commit comments

Comments
 (0)