react-router: False positives for active Links

The current implementation of pathnameIsActive gives false positives for what I’d expect to be a fairly common case: numbers in path parameters.

Just hit this in v1.0.0-beta2 in an app which is using the index of some items in an array as a parameter. Once you start hitting double-digit numbers, you get false positives from single-digit numbers.

rr-false-positives

In this example, the URL is /1/10 and links for both /1/1 and /1/10 are marked active.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 28 (12 by maintainers)

Most upvoted comments

I think #1842, <IndexRoute/> and <IndexLink/> address almost everything here.

Only thing missing is “I am active only when I’m the deepest active route”, would love for somebody to create a <ExactLink/> or <Link to="/wherever" exact/> or something.