1
0
mirror of synced 2026-01-08 12:01:53 -05:00

Merge pull request #25707 from github/repo-sync

repo sync
This commit is contained in:
Octomerger Bot
2023-05-25 16:03:04 -04:00
committed by GitHub
2 changed files with 19 additions and 0 deletions

View File

@@ -31,5 +31,10 @@ export default function handleInvalidPaths(req, res, next) {
return res.status(404).send('Not found')
}
if (req.path.endsWith('/index.md')) {
defaultCacheControl(res)
return res.redirect(req.path.replace(/\/index\.md$/, ''))
}
return next()
}

View File

@@ -0,0 +1,14 @@
import { head } from '../helpers/e2etest.js'
describe('bad URLs', () => {
test('any URL with /index.md suffix redirects to be without suffix', async () => {
const URLs = ['/index.md', '/en/index.md', '/en/actions/index.md']
for (const url of URLs) {
const res = await head(url)
expect(res.statusCode).toBe(302)
expect(res.headers.location).toBe(url.replace(/\/index\.md$/, ''))
expect(res.headers['cache-control']).toContain('public')
expect(res.headers['cache-control']).toMatch(/max-age=[1-9]/)
}
})
})