@umijs/route-utils
Advanced tools
Comparing version 1.0.24 to 1.0.25
@@ -26,3 +26,3 @@ import { pathToRegexp } from '@qixian.cs/path-to-regexp'; | ||
export const getMenuMatches = (flatMenuKeys = [], path, flatMenus) => flatMenuKeys | ||
.filter(item => { | ||
.filter((item) => { | ||
// 如果配置了 hideInMenu 就不需要选中了 | ||
@@ -35,10 +35,15 @@ if (flatMenus[item].hideInMenu) { | ||
} | ||
if (item !== '/' && item && !isUrl(item)) { | ||
// /a | ||
if (pathToRegexp(`${item}`, []).test(path)) { | ||
return true; | ||
if (item !== '/' && item !== '/*' && item && !isUrl(item)) { | ||
try { | ||
// /a | ||
if (pathToRegexp(`${item}`, []).test(path)) { | ||
return true; | ||
} | ||
// /a/b/b | ||
if (pathToRegexp(`${item}(.*)`).test(path)) { | ||
return true; | ||
} | ||
} | ||
// /a/b/b | ||
if (pathToRegexp(`${item}(.*)`).test(path)) { | ||
return true; | ||
catch (error) { | ||
console.log(error, path); | ||
} | ||
@@ -79,3 +84,3 @@ } | ||
const parentItems = (menuItem.pro_layout_parentKeys || []) | ||
.map(key => { | ||
.map((key) => { | ||
if (map.has(key)) { | ||
@@ -87,3 +92,3 @@ return null; | ||
}) | ||
.filter(item => item); | ||
.filter((item) => item); | ||
if (menuItem.key) { | ||
@@ -90,0 +95,0 @@ parentItems.push(menuItem); |
@@ -274,2 +274,7 @@ import getMatchMenu from './getMatchMenu'; | ||
{ path: '/tech-ui-preview/:category/:id', unaccessible: false }, | ||
{ | ||
// 其它路由情况, 用于兜底 | ||
path: '/*', | ||
redirect: './Exception/404', | ||
}, | ||
]; | ||
@@ -276,0 +281,0 @@ test('test layout config', () => { |
@@ -41,11 +41,15 @@ import { pathToRegexp } from '@qixian.cs/path-to-regexp'; | ||
if (item !== '/' && item && !isUrl(item)) { | ||
// /a | ||
if (pathToRegexp("".concat(item), []).test(path)) { | ||
return true; | ||
} // /a/b/b | ||
if (item !== '/' && item !== '/*' && item && !isUrl(item)) { | ||
try { | ||
// /a | ||
if (pathToRegexp("".concat(item), []).test(path)) { | ||
return true; | ||
} // /a/b/b | ||
if (pathToRegexp("".concat(item, "(.*)")).test(path)) { | ||
return true; | ||
if (pathToRegexp("".concat(item, "(.*)")).test(path)) { | ||
return true; | ||
} | ||
} catch (error) { | ||
console.log(error, path); | ||
} | ||
@@ -52,0 +56,0 @@ } |
@@ -55,11 +55,15 @@ "use strict"; | ||
if (item !== '/' && item && !(0, _transformRoute.isUrl)(item)) { | ||
// /a | ||
if ((0, _pathToRegexp.pathToRegexp)("".concat(item), []).test(path)) { | ||
return true; | ||
} // /a/b/b | ||
if (item !== '/' && item !== '/*' && item && !(0, _transformRoute.isUrl)(item)) { | ||
try { | ||
// /a | ||
if ((0, _pathToRegexp.pathToRegexp)("".concat(item), []).test(path)) { | ||
return true; | ||
} // /a/b/b | ||
if ((0, _pathToRegexp.pathToRegexp)("".concat(item, "(.*)")).test(path)) { | ||
return true; | ||
if ((0, _pathToRegexp.pathToRegexp)("".concat(item, "(.*)")).test(path)) { | ||
return true; | ||
} | ||
} catch (error) { | ||
console.log(error, path); | ||
} | ||
@@ -66,0 +70,0 @@ } |
{ | ||
"name": "@umijs/route-utils", | ||
"version": "1.0.24", | ||
"version": "1.0.25", | ||
"description": "Quickly process the routing of umi", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
318771
3765