react-navigation-browser-history-helpers icon indicating copy to clipboard operation
react-navigation-browser-history-helpers copied to clipboard

Issue when url finish with "/"

Open simonjoom opened this issue 7 years ago • 1 comments

I constated that the helper cannot find the correct route in case or the browser add "/" at the end.

nota my screens path never finish by "/"

I added in reducer one line:

 const { path, params = {} } = Navigator.router.getPathAndParamsForState(state);
  //->  
  let pathf = path.lastIndexOf('/') !== -1 ? path.slice(0, path.lastIndexOf('/')) : path;
  //   
   const qs = queryToString(params);
      if (!action.dontPushHistory) {
        history.push({
          pathname: `${basePath}${pathf}`,
          search: qs,
        });
      }

same in browser history:

     setNavFromPath = (path) => {
       let pathWithoutQuery = path.indexOf('?') !== -1 ? path.slice(0, path.indexOf('?')) : path;
       pathWithoutQuery = path.lastIndexOf('/') !== -1 ? path.slice(0, path.lastIndexOf('/')) : path;
 

simonjoom avatar Aug 25 '18 22:08 simonjoom

This sounds like the route are created with strict: true in term of react-router <Route /> terms. Did you sort this out?

kopax avatar Jan 04 '20 07:01 kopax