Skip to content

Commit

Permalink
Fix non-exact isActive
Browse files Browse the repository at this point in the history
  • Loading branch information
taion committed Nov 6, 2016
1 parent ab0fc65 commit df7c504
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Matcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,21 @@ export default class Matcher {
}

isPathnameActive(matchPathname, pathname, exact) {
if (pathname === matchPathname) {
return true;
}

if (exact) {
return pathname === matchPathname;
// The above condition is necessary for an exact match.
return false;
}

// Require that a partial match is followed by a path separator.
const pathnameWithSeparator = pathname.slice(-1) !== '/' ?
`${pathname}/` : pathname;

// Can't use startsWith, as that requires a polyfill.
return matchPathname.indexOf(pathname) === 0;
return matchPathname.indexOf(pathnameWithSeparator) === 0;
}

isQueryActive(matchQuery, query) {
Expand Down

0 comments on commit df7c504

Please sign in to comment.