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 <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 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)