Skip to content

Commit

Permalink
os: improve path check with direct index access
Browse files Browse the repository at this point in the history
PR-URL: #55434
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
  • Loading branch information
mertcanaltin authored and ruyadorno committed Nov 27, 2024
1 parent 3477b6b commit 21ec855
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/os.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const {
Float64Array,
NumberParseInt,
ObjectDefineProperties,
StringPrototypeEndsWith,
StringPrototypeSlice,
SymbolToPrimitive,
} = primordials;
Expand Down Expand Up @@ -184,9 +183,9 @@ function tmpdir() {
process.env.TMP ||
(process.env.SystemRoot || process.env.windir) + '\\temp';

if (path.length > 1 && StringPrototypeEndsWith(path, '\\') &&
!StringPrototypeEndsWith(path, ':\\'))
if (path.length > 1 && path[path.length - 1] === '\\' && path[path.length - 2] !== ':') {
return StringPrototypeSlice(path, 0, -1);
}

return path;
}
Expand Down

0 comments on commit 21ec855

Please sign in to comment.