Skip to content

Commit 62ef408

Browse files
committed
server-node: Added back missing .shortcuts.json parsing
1 parent 9f764e1 commit 62ef408

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,33 @@ const VFS = {
485485

486486
scandir: function(http, args, resolve, reject) {
487487
const resolved = _vfs.parseVirtualPath(args.path, http);
488-
readDir(resolved.query, resolved.real).then(resolve).catch(reject);
488+
const opts = args.options || {};
489+
490+
readDir(resolved.query, resolved.real).then(function(list) {
491+
492+
if ( opts.shortcuts !== false ) {
493+
const filename = typeof opts.shortcuts === 'string' ? opts.shortcuts.replace(/\/+g/, '') : '.shortcuts.json';
494+
const path = args.path.replace(/\/?$/, '/' + filename);
495+
const realMeta = _vfs.parseVirtualPath(path, http);
496+
497+
_fs.readFile(realMeta.real, function(err, contents) {
498+
var additions = [];
499+
if ( !err ) {
500+
try {
501+
additions = JSON.parse(contents.toString());
502+
if ( !(additions instanceof Array) ) {
503+
additions = [];
504+
}
505+
} catch ( e ) {}
506+
}
507+
508+
resolve(list.concat(additions));
509+
});
510+
} else {
511+
resolve(list);
512+
}
513+
514+
}).catch(reject);
489515
},
490516

491517
freeSpace: function(http, args, resolve, reject) {

0 commit comments

Comments
 (0)