throw if we are passed the empty string - we know this won't work

Signed-off-by: David Roberts <David.Roberts@orbis.com>
This commit is contained in:
David Roberts
2024-02-12 16:49:47 +00:00
parent a29f6833bb
commit 184c8877c9
2 changed files with 12 additions and 0 deletions
@@ -572,6 +572,14 @@ describe('createRouter', () => {
expect(response.status).toEqual(400);
});
});
describe('GET /readme/:projectName/:repoName with a bad readme path (empty string)', () => {
it('throws InputError', async () => {
const response = await request(app).get('/readme/myProject/myRepo?path=');
expect(azureDevOpsApi.getReadme).not.toHaveBeenCalled();
expect(response.status).toEqual(400);
});
});
});
function getReadmeMock() {
@@ -228,6 +228,10 @@ export async function createRouter(
throw new InputError('Invalid path param');
}
if (path === '') {
throw new InputError('If present, the path param should not be empty');
}
const { projectName, repoName } = req.params;
const readme = await azureDevOpsApi.getReadme(
host,