Unverified Commit 1674f2de authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Add check that dynamic route is API route in handleApiRequest (#10360)

* Add failing test case

* Add check that dynamic route is API route in handleApiRequest
parent afc278f5
......@@ -644,7 +644,7 @@ export default class Server {
if (!pageFound && this.dynamicRoutes) {
for (const dynamicRoute of this.dynamicRoutes) {
params = dynamicRoute.match(pathname)
if (params) {
if (dynamicRoute.page.startsWith('/api') && params) {
page = dynamicRoute.page
pageFound = true
break
......
......@@ -61,6 +61,12 @@ function runTests(dev) {
expect(html).toMatch(/blog post.*321.*comment.*123/i)
})
it('should not error when requesting dynamic page with /api', async () => {
const res = await fetchViaHTTP(appPort, '/api')
expect(res.status).toBe(200)
expect(await res.text()).toMatch(/this is.*?api/i)
})
it('should render dynamic route with query', async () => {
const browser = await webdriver(appPort, '/')
await browser.elementByCss('#view-post-1-with-query').click()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment