fix(route) unable to navigate between folders (#333)

This commit is contained in:
coderaiser 2021-03-16 17:44:54 +02:00
parent 21e7ea7d4c
commit df60dd7ba0
2 changed files with 36 additions and 2 deletions

View file

@ -79,7 +79,10 @@ async function route({config, options, request, response}) {
const fullPath = root(rootName, config('root'));
const read = getReadDir(config);
const [error, stream] = await tryToCatch(read, fullPath);
const [error, stream] = await tryToCatch(read, fullPath, {
root: config('root'),
});
const {html} = options;
if (error)

View file

@ -28,7 +28,6 @@ const {request} = serveOnce(cloudcmd, {
});
const {stringify} = JSON;
const {assign} = Object;
test('cloudcmd: route: buttons: no console', async (t) => {
@ -459,3 +458,35 @@ test('cloudcmd: route: content length', async (t) => {
t.end();
});
test('cloudcmd: route: read: root', async (t) => {
const read = stub();
mockRequire('win32', {
read,
});
reRequire(routePath);
const cloudcmd = reRequire(cloudcmdPath);
const configManager = createConfigManager();
const root = '/hello';
configManager('root', root);
const {request} = serveOnce(cloudcmd, {
configManager,
});
await request.get('/fs/route.js');
stopAll();
const expected = [
'/hello/route.js', {
root,
},
];
t.calledWith(read, expected);
t.end();
});