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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user