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

Root Wildcard is too Greedy #26

Closed
lukeed opened this issue Feb 9, 2018 · 0 comments
Closed

Root Wildcard is too Greedy #26

lukeed opened this issue Feb 9, 2018 · 0 comments
Labels

Comments

@lukeed
Copy link
Owner

lukeed commented Feb 9, 2018

Using a root wildcard (/*) is a little too greedy, meaning that it prevents any sub-apps or bware from running.

As mentioned here, this is problematic:

let noop = () => {};

polka()
  .use('foo', noop)
  .use('bar', noop)
  .get('*', (req, res) => {
    res.end('THIS ALWAYS RUNS')
  })
  .listen(PORT)

The simplest way around this is to move the get('*') into options.onNoMatch, but that's probably too different from Express. It also doesn't constrain to GET requests.

const onNoMatch = (req, res) => {
  res.end('THIS ALWAYS RUNS')
});

polka({ onNoMatch })
  .use('foo', noop)
  .use('bar', noop)
@lukeed lukeed added the bug label Feb 9, 2018
@lukeed lukeed closed this as completed in dfac4b4 Feb 9, 2018
lukeed added a commit that referenced this issue Feb 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant