mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
useRouteActive validation improved
This commit is contained in:
parent
80ac864ea0
commit
9ed75f3a32
1 changed files with 2 additions and 2 deletions
|
|
@ -5,8 +5,8 @@ const useLocationHash = require('stremio/common/useLocationHash');
|
|||
const useRouteActive = (routeRegexp) => {
|
||||
const locationHash = useLocationHash();
|
||||
const active = React.useMemo(() => {
|
||||
const { pathname: locationPathname } = UrlUtils.parse(locationHash.slice(1));
|
||||
return routeRegexp instanceof RegExp && !!locationPathname.match(routeRegexp);
|
||||
const { pathname } = UrlUtils.parse(locationHash.slice(1));
|
||||
return typeof pathname === 'string' && routeRegexp instanceof RegExp && !!pathname.match(routeRegexp);
|
||||
}, [locationHash, routeRegexp]);
|
||||
return active;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue