path: refactor logic for to reduce code branches
This refactoring makes sure some code branches will not be hit if they do not have to be reached. PR-URL: https://github.com/nodejs/node/pull/25278 Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
parent
f59fdd9d65
commit
e750e9583e
30
lib/path.js
30
lib/path.js
@ -224,23 +224,25 @@ const win32 = {
|
||||
isAbsolute = true;
|
||||
}
|
||||
|
||||
if (device.length > 0 &&
|
||||
resolvedDevice.length > 0 &&
|
||||
device.toLowerCase() !== resolvedDevice.toLowerCase()) {
|
||||
// This path points to another device so it is not applicable
|
||||
continue;
|
||||
if (device.length > 0) {
|
||||
if (resolvedDevice.length > 0) {
|
||||
if (device.toLowerCase() !== resolvedDevice.toLowerCase())
|
||||
// This path points to another device so it is not applicable
|
||||
continue;
|
||||
} else {
|
||||
resolvedDevice = device;
|
||||
}
|
||||
}
|
||||
|
||||
if (resolvedDevice.length === 0 && device.length > 0) {
|
||||
resolvedDevice = device;
|
||||
}
|
||||
if (!resolvedAbsolute) {
|
||||
resolvedTail = path.slice(rootEnd) + '\\' + resolvedTail;
|
||||
if (resolvedAbsolute) {
|
||||
if (resolvedDevice.length > 0)
|
||||
break;
|
||||
} else {
|
||||
resolvedTail = `${path.slice(rootEnd)}\\${resolvedTail}`;
|
||||
resolvedAbsolute = isAbsolute;
|
||||
}
|
||||
|
||||
if (resolvedDevice.length > 0 && resolvedAbsolute) {
|
||||
break;
|
||||
if (isAbsolute && resolvedDevice.length > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user