visionmedia / page.js

Micro client-side router inspired by the Express router
http://visionmedia.github.com/page.js
7.67k stars 687 forks source link

Regex capture groups not reflected in context parameters #538

Open mclotworthy opened 5 years ago

mclotworthy commented 5 years ago

Considering the route: /^\/inbox(?:\/?(actionable|other))?$/

A match will be made for URI: http://SomeMailServer/inbox

With expected context.params: { 0: undefined }

Currently pagejs returns an unexpected context.params of: { 0: "/inbox" }

mclotworthy commented 5 years ago

In Route.prototype.match the loop starts from index 1 with the expectation that there will always be defined value for the first capture group. Suggest delete params[0] before beginning the loop that populates params.