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;
|
isAbsolute = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device.length > 0 &&
|
if (device.length > 0) {
|
||||||
resolvedDevice.length > 0 &&
|
if (resolvedDevice.length > 0) {
|
||||||
device.toLowerCase() !== resolvedDevice.toLowerCase()) {
|
if (device.toLowerCase() !== resolvedDevice.toLowerCase())
|
||||||
// This path points to another device so it is not applicable
|
// This path points to another device so it is not applicable
|
||||||
continue;
|
continue;
|
||||||
|
} else {
|
||||||
|
resolvedDevice = device;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resolvedDevice.length === 0 && device.length > 0) {
|
if (resolvedAbsolute) {
|
||||||
resolvedDevice = device;
|
if (resolvedDevice.length > 0)
|
||||||
}
|
break;
|
||||||
if (!resolvedAbsolute) {
|
} else {
|
||||||
resolvedTail = path.slice(rootEnd) + '\\' + resolvedTail;
|
resolvedTail = `${path.slice(rootEnd)}\\${resolvedTail}`;
|
||||||
resolvedAbsolute = isAbsolute;
|
resolvedAbsolute = isAbsolute;
|
||||||
}
|
if (isAbsolute && resolvedDevice.length > 0) {
|
||||||
|
break;
|
||||||
if (resolvedDevice.length > 0 && resolvedAbsolute) {
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user