Skip to content

Commit 21ec855

Browse files
mertcanaltinruyadorno
authored andcommitted
os: improve path check with direct index access
PR-URL: #55434 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
1 parent 3477b6b commit 21ec855

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/os.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const {
2626
Float64Array,
2727
NumberParseInt,
2828
ObjectDefineProperties,
29-
StringPrototypeEndsWith,
3029
StringPrototypeSlice,
3130
SymbolToPrimitive,
3231
} = primordials;
@@ -184,9 +183,9 @@ function tmpdir() {
184183
process.env.TMP ||
185184
(process.env.SystemRoot || process.env.windir) + '\\temp';
186185

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

191190
return path;
192191
}

0 commit comments

Comments
 (0)