Skip to content

Using two routers, the next bug of regular routing #139

@1stgg

Description

@1stgg

node.js version: v14.17.6

npm/yarn and version: 1.22.11

@koa/router version: 10.1.1

koa version: 2.13.4

Code sample:

let app = new (require("koa"))()
let routerA = new (require("koa-router"))()
let routerB = new (require("koa-router"))()


routerA.get('/test/(.*?)', async (ctx,next) => {
  console.log('/test/(.*?)');
  await next()
})
routerB.get('/test/child', async (ctx) => {
  ctx.body = '/test/child';
})



app.use(routerA.routes())
app.use(routerB.routes())

app.listen(3000, () => {
  console.log('应用已经启动,http://localhost:3000');
})

Expected Behavior:

GET http://localhost:3000/test/child
response.body = '/test/child'

Actual Behavior:

GET http://localhost:3000/test/child
response 404 Not Found

Additional steps, HTTP request details, or to reproduce the behavior or a test case:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions