listpage-next 0.0.42 → 0.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,13 +23,14 @@ function useActiveMenuKey(items, baseUrl = '') {
23
23
  }
24
24
  const paths = findKeyPath(items, []);
25
25
  const urlPath = paths.map((p)=>getPaths(p)).flat().join('/');
26
- navigate(baseUrl + '/' + urlPath);
26
+ navigate(urlPath);
27
27
  }, [
28
28
  items,
29
29
  navigate
30
30
  ]);
31
31
  const activeKey = useMemo(()=>{
32
32
  const filteredPaths = removeBaseUrl(location.pathname, baseUrl);
33
+ debugger;
33
34
  const paths = getPaths(filteredPaths);
34
35
  return matchRoutes(items, paths);
35
36
  }, [
@@ -43,17 +44,8 @@ function useActiveMenuKey(items, baseUrl = '') {
43
44
  ];
44
45
  }
45
46
  const removeBaseUrl = (pathname, baseUrl)=>{
46
- if ('' === baseUrl) return pathname;
47
- let normalizedBaseUrl = baseUrl;
48
- if (!baseUrl.startsWith('/')) normalizedBaseUrl = '/' + baseUrl;
49
- let normalizedPathname = pathname;
50
- if (!pathname.startsWith('/')) normalizedPathname = '/' + pathname;
51
- if (normalizedPathname.startsWith(normalizedBaseUrl)) {
52
- if (normalizedPathname === normalizedBaseUrl || '/' === normalizedPathname.charAt(normalizedBaseUrl.length)) {
53
- const result = normalizedPathname.substring(normalizedBaseUrl.length);
54
- return '' === result ? '/' : result.startsWith('/') ? result : '/' + result;
55
- }
56
- }
47
+ if (!baseUrl) return pathname;
48
+ if (pathname.startsWith(baseUrl)) return pathname.slice(baseUrl.length);
57
49
  return pathname;
58
50
  };
59
51
  const matchRoutes = (routes, paths)=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listpage-next",
3
- "version": "0.0.42",
3
+ "version": "0.0.43",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",