validate that 'pathname' is not repeated as query (#37319)
This commit is contained in:
@@ -21,6 +21,9 @@ const validationMiddleware = (req, res, next) => {
|
||||
if (!pathname) {
|
||||
return res.status(400).json({ error: `No 'pathname' query` })
|
||||
}
|
||||
if (Array.isArray(pathname)) {
|
||||
return res.status(400).json({ error: "Multiple 'pathname' keys" })
|
||||
}
|
||||
if (!pathname.trim()) {
|
||||
return res.status(400).json({ error: `'pathname' query empty` })
|
||||
}
|
||||
|
||||
@@ -63,6 +63,13 @@ describe('pageinfo api', () => {
|
||||
expect(error).toBe("'pathname' query empty")
|
||||
})
|
||||
|
||||
test('repeated pathname query string key', async () => {
|
||||
const res = await get('/api/pageinfo/v1?pathname=a&pathname=b')
|
||||
expect(res.statusCode).toBe(400)
|
||||
const { error } = JSON.parse(res.body)
|
||||
expect(error).toBe("Multiple 'pathname' keys")
|
||||
})
|
||||
|
||||
test('redirects correct the URL', async () => {
|
||||
// Regular redirect from `redirect_from`
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user