Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fs: readdir fails when libuv returns UV_DIRENT_UNKNOWN and the first …
…arg is Buffer
  • Loading branch information
kkz13250 committed Jun 25, 2020
commit 7b3f49da53dcd241f486bb45b683e47e00a9513f
40 changes: 34 additions & 6 deletions lib/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,20 +370,48 @@ const win32 = {

let joined;
let firstPart;
let isType;
for (let i = 0; i < args.length; ++i) {
const arg = args[i];
validateString(arg, 'path');
if (arg.length > 0) {
if (joined === undefined)
joined = firstPart = arg;
else
joined += `\\${arg}`;
if (typeof arg == 'string'){
if (arg.length > 0) {
if (joined === undefined){
joined = firstPart = arg;
isType = 'string';
}
else{
if (isType == 'string'){
joined += `\\${arg}`;
} else {
const argBuffer = Buffer.from(`\\${arg}`);
joined = Buffer.concat([joined, argBuffer]);
}
}
}
} else if (typeof arg == 'buffer'){
if (arg.length > 0) {
if (joined === undefined){
joined = firstPart = arg;
isType = 'buffer';
}
else{
if (isType == 'string'){
const joinedBuffer = Buffer.from(joined);
joined = Buffer.concat([joinedBuffer,Buffer.from(pathModule.sep),arg]);
} else {
joined = Buffer.concat([joined,Buffer.from(pathModule.sep),arg]);
}
}
}
} else {
validateString(arg, 'path');
}
}

if (joined === undefined)
return '.';


// Make sure that the joined path doesn't start with two slashes, because
// normalize() will mistake it for a UNC path then.
//
Expand Down