mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
fix(route) unable to navigate between folders (#333)
This commit is contained in:
parent
21e7ea7d4c
commit
df60dd7ba0
2 changed files with 36 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue