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 <luigipinca@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
  • Loading branch information
mertcanaltin authored and ruyadorno committed Nov 27, 2024
1 parent a428ebc commit bd0cc84
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 bd0cc84

Please sign in to comment.