Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the merge relationship between prefix and path #486

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cevio
Copy link

@cevio cevio commented Nov 4, 2018

Fix the merge relationship between prefix and path, so that path-to-regexp can correctly parse the regular expression.

I found the bug:

const Koa = require('koa');
const Router = require('koa-router');

const app = new Koa();
const router = new Router();

const test = new Router();

test.get('/test', async (ctx, next) => {
  ctx.body = 'hello world';
});

router.use('/abc', test.routes(), test.allowedMethods());

app.use(router.routes());
app.use(router.allowedMethods());

app.listen(9000);

When i view '/abc/test' , the result is '404';

if

test.get('/', async (ctx, next) => {
  ctx.body = 'hello world';
});
router.use('/', test.routes(), test.allowedMethods());

Also got 404. I fixed it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant