Skip to content

Commit 9a839c0

Browse files
committed
server-node: Fixed issues with path resolve in 'find()'
1 parent 3b70424 commit 9a839c0

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/server/node/modules/vfs/filesystem.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -439,27 +439,23 @@ const VFS = {
439439

440440
var list = [];
441441

442+
function addIter(file, stat) {
443+
const filename = _path.basename(file).toLowerCase();
444+
const fpath = resolved.path + file.substr(resolved.real.length).replace(/^\//, '');
445+
if ( filename.indexOf(query) !== -1 ) {
446+
const qpath = resolved.query + fpath.replace(/^\//, '');
447+
list.push(createFileIter(qpath, resolved.real, null, stat));
448+
}
449+
}
450+
442451
find.on('path', function() {
443452
if ( qargs.limit && list.length >= qargs.limit ) {
444453
find.stop();
445454
}
446455
});
447456

448-
find.on('directory', function(dir, stat) {
449-
const filename = _path.basename(dir).toLowerCase();
450-
const fpath = resolved.path + dir.substr(resolved.real.length).replace(/^\//, '');
451-
if ( filename.indexOf(query) !== -1 ) {
452-
list.push(createFileIter(fpath, resolved.real, null, stat));
453-
}
454-
});
455-
456-
find.on('file', function(file, stat) {
457-
const filename = _path.basename(file).toLowerCase();
458-
const fpath = resolved.path + file.substr(resolved.real.length).replace(/^\//, '');
459-
if ( filename.indexOf(query) !== -1 ) {
460-
list.push(createFileIter(fpath, resolved.real, null, stat));
461-
}
462-
});
457+
find.on('directory', addIter);
458+
find.on('file', addIter);
463459

464460
find.on('end', function() {
465461
resolve(list);

0 commit comments

Comments
 (0)