@umijs/route-utils
Advanced tools
Comparing version 1.0.30 to 1.0.31
@@ -0,1 +1,2 @@ | ||
import { stripQueryStringAndHashFromPath } from '../transformRoute/transformRoute'; | ||
/** | ||
@@ -12,3 +13,5 @@ * 获取打平的 menuData | ||
} | ||
menus[item.path || item.key || '/'] = { ...item }; | ||
menus[stripQueryStringAndHashFromPath(item.path || item.key || '/')] = { | ||
...item, | ||
}; | ||
menus[item.key || item.path || '/'] = { ...item }; | ||
@@ -15,0 +18,0 @@ if (item.children) { |
import { MenuDataItem } from '../types'; | ||
export declare const getMenuMatches: (flatMenuKeys: string[] | undefined, path: string) => string | undefined; | ||
/** | ||
* a-b-c | ||
* [ | ||
* "a", | ||
* "a-b", | ||
* "a-b-c" | ||
* ] | ||
* @param menuKey | ||
*/ | ||
export declare const genKeysToArray: (menuKey: string) => string[]; | ||
export declare const getMenuMatches: (flatMenuKeys: string[] | undefined, path: string, flatMenus: { | ||
[key: string]: MenuDataItem; | ||
}) => string | undefined; | ||
/** | ||
* 获取当前的选中菜单列表 | ||
@@ -17,0 +5,0 @@ * @param pathname |
import { pathToRegexp } from '@qixian.cs/path-to-regexp'; | ||
import getFlatMenu from '../getFlatMenus/getFlatMenus'; | ||
import { isUrl } from '../transformRoute/transformRoute'; | ||
/** | ||
* a-b-c | ||
* [ | ||
* "a", | ||
* "a-b", | ||
* "a-b-c" | ||
* ] | ||
* @param menuKey | ||
*/ | ||
export const genKeysToArray = (menuKey) => { | ||
const keys = menuKey.split('-'); | ||
const keyArray = []; | ||
keys.forEach((key, index) => { | ||
if (index === 0) { | ||
keyArray.push(key); | ||
return; | ||
} | ||
keyArray.push(keys.slice(0, index + 1).join('-')); | ||
}); | ||
return keyArray; | ||
}; | ||
export const getMenuMatches = (flatMenuKeys = [], path, flatMenus) => flatMenuKeys | ||
import { isUrl, stripQueryStringAndHashFromPath, } from '../transformRoute/transformRoute'; | ||
export const getMenuMatches = (flatMenuKeys = [], path) => flatMenuKeys | ||
.filter((item) => { | ||
@@ -31,9 +10,10 @@ if (item === '/' && path === '/') { | ||
if (item !== '/' && item !== '/*' && item && !isUrl(item)) { | ||
const pathKey = stripQueryStringAndHashFromPath(item); | ||
try { | ||
// /a | ||
if (pathToRegexp(`${item}`, []).test(path)) { | ||
if (pathToRegexp(`${pathKey}`, []).test(path)) { | ||
return true; | ||
} | ||
// /a/b/b | ||
if (pathToRegexp(`${item}(.*)`).test(path)) { | ||
if (pathToRegexp(`${pathKey}(.*)`).test(path)) { | ||
return true; | ||
@@ -43,3 +23,3 @@ } | ||
catch (error) { | ||
console.log(error, path); | ||
// console.log(error, path); | ||
} | ||
@@ -69,3 +49,3 @@ } | ||
const flatMenuKeys = Object.keys(flatMenus); | ||
const menuPathKey = getMenuMatches(flatMenuKeys, pathname || '/', flatMenus); | ||
const menuPathKey = getMenuMatches(flatMenuKeys, pathname || '/'); | ||
if (!menuPathKey) { | ||
@@ -72,0 +52,0 @@ return []; |
import { MenuDataItem, Route, MessageDescriptor } from '../types'; | ||
export declare function stripQueryStringAndHashFromPath(url: string): string; | ||
export declare const isUrl: (path: string) => boolean; | ||
export declare function guid(): string; | ||
export declare const getKeyByPath: (item: MenuDataItem) => string; | ||
export declare const getKeyByPath: (item: MenuDataItem) => string | undefined; | ||
/** | ||
@@ -6,0 +6,0 @@ * @param routes 路由配置 |
@@ -5,3 +5,3 @@ import isEqual from 'lodash.isequal'; | ||
import { pathToRegexp } from '@qixian.cs/path-to-regexp'; | ||
function stripQueryStringAndHashFromPath(url) { | ||
export function stripQueryStringAndHashFromPath(url) { | ||
return url.split('?')[0].split('#')[0]; | ||
@@ -12,25 +12,14 @@ } | ||
export const isUrl = (path) => reg.test(path); | ||
export function guid() { | ||
return 'xxxxxxxx'.replace(/[xy]/g, (c) => { | ||
// eslint-disable-next-line no-bitwise | ||
const r = (Math.random() * 16) | 0; | ||
// eslint-disable-next-line no-bitwise | ||
const v = c === 'x' ? r : (r & 0x3) | 0x8; | ||
return v.toString(16); | ||
}); | ||
} | ||
export const getKeyByPath = (item) => { | ||
const { path } = item; | ||
if (path && path !== '/') { | ||
return path; | ||
if (!path || path === '/') { | ||
// 如果还是没有,用对象的hash 生成一个 | ||
try { | ||
return `/${hash.sha256().update(JSON.stringify(item)).digest('hex')}`; | ||
} | ||
catch (error) { | ||
// dom some thing | ||
} | ||
} | ||
// 如果还是没有,用对象的hash 生成一个 | ||
try { | ||
return `/${hash.sha256().update(JSON.stringify(item)).digest('hex')}`; | ||
} | ||
catch (error) { | ||
// dom some thing | ||
} | ||
// 要是还是不行,返回一个随机值 | ||
return guid(); | ||
return path ? stripQueryStringAndHashFromPath(path) : path; | ||
}; | ||
@@ -140,2 +129,3 @@ /** | ||
if (item.unaccessible) { | ||
// eslint-disable-next-line no-param-reassign | ||
delete item.name; | ||
@@ -146,6 +136,2 @@ } | ||
} | ||
// 兼容性,bigfish的兼容 | ||
if (item?.indexRoute?.menu?.name || item?.indexRoute?.menu?.flatMenu) { | ||
return true; | ||
} | ||
// 显示指定在 menu 中隐藏该项 | ||
@@ -159,3 +145,3 @@ // layout 插件的功能,其实不应该存在的 | ||
.map((item = { path: '/' }) => { | ||
const path = stripQueryStringAndHashFromPath(mergePath(item.path, parent ? parent.path : '/')); | ||
const path = mergePath(item.path, parent ? parent.path : '/'); | ||
const { name } = item; | ||
@@ -236,10 +222,16 @@ const locale = getItemLocaleName(item, parentName || 'menu'); | ||
let routeValue; | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (const [key, value] of this.entries()) { | ||
if (!isUrl(key) && | ||
pathToRegexp(key, []).test(pathname)) { | ||
routeValue = value; | ||
break; | ||
try { | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (const [key, value] of this.entries()) { | ||
const path = stripQueryStringAndHashFromPath(key); | ||
if (!isUrl(key) && | ||
pathToRegexp(path, []).test(pathname)) { | ||
routeValue = value; | ||
break; | ||
} | ||
} | ||
} | ||
catch (error) { | ||
routeValue = undefined; | ||
} | ||
return routeValue; | ||
@@ -257,5 +249,2 @@ } | ||
data.forEach((menuItem) => { | ||
if (!menuItem) { | ||
return; | ||
} | ||
if (menuItem && menuItem.children) { | ||
@@ -266,3 +255,3 @@ flattenMenuData(menuItem.children, menuItem); | ||
const path = mergePath(menuItem.path, parent ? parent.path : '/'); | ||
routerMap.set(path, menuItem); | ||
routerMap.set(stripQueryStringAndHashFromPath(path), menuItem); | ||
}); | ||
@@ -269,0 +258,0 @@ }; |
@@ -7,2 +7,3 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
import { stripQueryStringAndHashFromPath } from '../transformRoute/transformRoute'; | ||
/** | ||
@@ -13,2 +14,3 @@ * 获取打平的 menuData | ||
*/ | ||
export var getFlatMenus = function getFlatMenus() { | ||
@@ -22,3 +24,3 @@ var menuData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
menus[item.path || item.key || '/'] = _objectSpread({}, item); | ||
menus[stripQueryStringAndHashFromPath(item.path || item.key || '/')] = _objectSpread({}, item); | ||
menus[item.key || item.path || '/'] = _objectSpread({}, item); | ||
@@ -25,0 +27,0 @@ |
import { pathToRegexp } from '@qixian.cs/path-to-regexp'; | ||
import getFlatMenu from '../getFlatMenus/getFlatMenus'; | ||
import { isUrl } from '../transformRoute/transformRoute'; | ||
/** | ||
* a-b-c | ||
* [ | ||
* "a", | ||
* "a-b", | ||
* "a-b-c" | ||
* ] | ||
* @param menuKey | ||
*/ | ||
export var genKeysToArray = function genKeysToArray(menuKey) { | ||
var keys = menuKey.split('-'); | ||
var keyArray = []; | ||
keys.forEach(function (key, index) { | ||
if (index === 0) { | ||
keyArray.push(key); | ||
return; | ||
} | ||
keyArray.push(keys.slice(0, index + 1).join('-')); | ||
}); | ||
return keyArray; | ||
}; | ||
import { isUrl, stripQueryStringAndHashFromPath } from '../transformRoute/transformRoute'; | ||
export var getMenuMatches = function getMenuMatches() { | ||
var flatMenuKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
var path = arguments.length > 1 ? arguments[1] : undefined; | ||
var flatMenus = arguments.length > 2 ? arguments[2] : undefined; | ||
return flatMenuKeys.filter(function (item) { | ||
@@ -37,5 +13,7 @@ if (item === '/' && path === '/') { | ||
if (item !== '/' && item !== '/*' && item && !isUrl(item)) { | ||
var pathKey = stripQueryStringAndHashFromPath(item); | ||
try { | ||
// /a | ||
if (pathToRegexp("".concat(item), []).test(path)) { | ||
if (pathToRegexp("".concat(pathKey), []).test(path)) { | ||
return true; | ||
@@ -45,7 +23,6 @@ } // /a/b/b | ||
if (pathToRegexp("".concat(item, "(.*)")).test(path)) { | ||
if (pathToRegexp("".concat(pathKey, "(.*)")).test(path)) { | ||
return true; | ||
} | ||
} catch (error) { | ||
console.log(error, path); | ||
} catch (error) {// console.log(error, path); | ||
} | ||
@@ -78,3 +55,3 @@ } | ||
var flatMenuKeys = Object.keys(flatMenus); | ||
var menuPathKey = getMenuMatches(flatMenuKeys, pathname || '/', flatMenus); | ||
var menuPathKey = getMenuMatches(flatMenuKeys, pathname || '/'); | ||
@@ -81,0 +58,0 @@ if (!menuPathKey) { |
@@ -65,4 +65,3 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
import { pathToRegexp } from '@qixian.cs/path-to-regexp'; | ||
function stripQueryStringAndHashFromPath(url) { | ||
export function stripQueryStringAndHashFromPath(url) { | ||
return url.split('?')[0].split('#')[0]; | ||
@@ -72,3 +71,2 @@ } | ||
var reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; | ||
@@ -78,26 +76,14 @@ export var isUrl = function isUrl(path) { | ||
}; | ||
export function guid() { | ||
return 'xxxxxxxx'.replace(/[xy]/g, function (c) { | ||
// eslint-disable-next-line no-bitwise | ||
var r = Math.random() * 16 | 0; // eslint-disable-next-line no-bitwise | ||
var v = c === 'x' ? r : r & 0x3 | 0x8; | ||
return v.toString(16); | ||
}); | ||
} | ||
export var getKeyByPath = function getKeyByPath(item) { | ||
var path = item.path; | ||
if (path && path !== '/') { | ||
return path; | ||
} // 如果还是没有,用对象的hash 生成一个 | ||
if (!path || path === '/') { | ||
// 如果还是没有,用对象的hash 生成一个 | ||
try { | ||
return "/".concat(hash.sha256().update(JSON.stringify(item)).digest('hex')); | ||
} catch (error) {// dom some thing | ||
} | ||
} | ||
try { | ||
return "/".concat(hash.sha256().update(JSON.stringify(item)).digest('hex')); | ||
} catch (error) {// dom some thing | ||
} // 要是还是不行,返回一个随机值 | ||
return guid(); | ||
return path ? stripQueryStringAndHashFromPath(path) : path; | ||
}; | ||
@@ -229,3 +215,3 @@ /** | ||
}).filter(function (item) { | ||
var _item$menu, _item$menu2, _item$indexRoute, _item$indexRoute$menu, _item$indexRoute2, _item$indexRoute2$men; | ||
var _item$menu, _item$menu2; | ||
@@ -235,2 +221,3 @@ // 是否没有权限查看 | ||
if (item.unaccessible) { | ||
// eslint-disable-next-line no-param-reassign | ||
delete item.name; | ||
@@ -241,7 +228,2 @@ } | ||
return true; | ||
} // 兼容性,bigfish的兼容 | ||
if ((item === null || item === void 0 ? void 0 : (_item$indexRoute = item.indexRoute) === null || _item$indexRoute === void 0 ? void 0 : (_item$indexRoute$menu = _item$indexRoute.menu) === null || _item$indexRoute$menu === void 0 ? void 0 : _item$indexRoute$menu.name) || (item === null || item === void 0 ? void 0 : (_item$indexRoute2 = item.indexRoute) === null || _item$indexRoute2 === void 0 ? void 0 : (_item$indexRoute2$men = _item$indexRoute2.menu) === null || _item$indexRoute2$men === void 0 ? void 0 : _item$indexRoute2$men.flatMenu)) { | ||
return true; | ||
} // 显示指定在 menu 中隐藏该项 | ||
@@ -260,3 +242,3 @@ // layout 插件的功能,其实不应该存在的 | ||
}; | ||
var path = stripQueryStringAndHashFromPath(mergePath(item.path, parent ? parent.path : '/')); | ||
var path = mergePath(item.path, parent ? parent.path : '/'); | ||
var name = item.name; | ||
@@ -359,22 +341,29 @@ var locale = getItemLocaleName(item, parentName || 'menu'); // if enableMenuLocale use item.name, | ||
value: function get(pathname) { | ||
var routeValue; // eslint-disable-next-line no-restricted-syntax | ||
var routeValue; | ||
var _iterator = _createForOfIteratorHelper(this.entries()), | ||
_step; | ||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var _step$value = _slicedToArray(_step.value, 2), | ||
key = _step$value[0], | ||
value = _step$value[1]; | ||
// eslint-disable-next-line no-restricted-syntax | ||
var _iterator = _createForOfIteratorHelper(this.entries()), | ||
_step; | ||
if (!isUrl(key) && pathToRegexp(key, []).test(pathname)) { | ||
routeValue = value; | ||
break; | ||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var _step$value = _slicedToArray(_step.value, 2), | ||
key = _step$value[0], | ||
value = _step$value[1]; | ||
var path = stripQueryStringAndHashFromPath(key); | ||
if (!isUrl(key) && pathToRegexp(path, []).test(pathname)) { | ||
routeValue = value; | ||
break; | ||
} | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
} catch (error) { | ||
routeValue = undefined; | ||
} | ||
@@ -400,6 +389,2 @@ | ||
data.forEach(function (menuItem) { | ||
if (!menuItem) { | ||
return; | ||
} | ||
if (menuItem && menuItem.children) { | ||
@@ -411,3 +396,3 @@ flattenMenuData(menuItem.children, menuItem); | ||
var path = mergePath(menuItem.path, parent ? parent.path : '/'); | ||
routerMap.set(path, menuItem); | ||
routerMap.set(stripQueryStringAndHashFromPath(path), menuItem); | ||
}); | ||
@@ -414,0 +399,0 @@ }; |
@@ -8,2 +8,4 @@ "use strict"; | ||
var _transformRoute = require("../transformRoute/transformRoute"); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
@@ -28,3 +30,3 @@ | ||
menus[item.path || item.key || '/'] = _objectSpread({}, item); | ||
menus[(0, _transformRoute.stripQueryStringAndHashFromPath)(item.path || item.key || '/')] = _objectSpread({}, item); | ||
menus[item.key || item.path || '/'] = _objectSpread({}, item); | ||
@@ -31,0 +33,0 @@ |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = exports.getMatchMenu = exports.getMenuMatches = exports.genKeysToArray = void 0; | ||
exports.default = exports.getMatchMenu = exports.getMenuMatches = void 0; | ||
@@ -17,31 +17,5 @@ var _pathToRegexp = require("@qixian.cs/path-to-regexp"); | ||
/** | ||
* a-b-c | ||
* [ | ||
* "a", | ||
* "a-b", | ||
* "a-b-c" | ||
* ] | ||
* @param menuKey | ||
*/ | ||
var genKeysToArray = function genKeysToArray(menuKey) { | ||
var keys = menuKey.split('-'); | ||
var keyArray = []; | ||
keys.forEach(function (key, index) { | ||
if (index === 0) { | ||
keyArray.push(key); | ||
return; | ||
} | ||
keyArray.push(keys.slice(0, index + 1).join('-')); | ||
}); | ||
return keyArray; | ||
}; | ||
exports.genKeysToArray = genKeysToArray; | ||
var getMenuMatches = function getMenuMatches() { | ||
var flatMenuKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
var path = arguments.length > 1 ? arguments[1] : undefined; | ||
var flatMenus = arguments.length > 2 ? arguments[2] : undefined; | ||
return flatMenuKeys.filter(function (item) { | ||
@@ -53,5 +27,7 @@ if (item === '/' && path === '/') { | ||
if (item !== '/' && item !== '/*' && item && !(0, _transformRoute.isUrl)(item)) { | ||
var pathKey = (0, _transformRoute.stripQueryStringAndHashFromPath)(item); | ||
try { | ||
// /a | ||
if ((0, _pathToRegexp.pathToRegexp)("".concat(item), []).test(path)) { | ||
if ((0, _pathToRegexp.pathToRegexp)("".concat(pathKey), []).test(path)) { | ||
return true; | ||
@@ -61,7 +37,6 @@ } // /a/b/b | ||
if ((0, _pathToRegexp.pathToRegexp)("".concat(item, "(.*)")).test(path)) { | ||
if ((0, _pathToRegexp.pathToRegexp)("".concat(pathKey, "(.*)")).test(path)) { | ||
return true; | ||
} | ||
} catch (error) { | ||
console.log(error, path); | ||
} catch (error) {// console.log(error, path); | ||
} | ||
@@ -97,3 +72,3 @@ } | ||
var flatMenuKeys = Object.keys(flatMenus); | ||
var menuPathKey = getMenuMatches(flatMenuKeys, pathname || '/', flatMenus); | ||
var menuPathKey = getMenuMatches(flatMenuKeys, pathname || '/'); | ||
@@ -100,0 +75,0 @@ if (!menuPathKey) { |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.guid = guid; | ||
exports.stripQueryStringAndHashFromPath = stripQueryStringAndHashFromPath; | ||
exports.default = exports.getKeyByPath = exports.isUrl = void 0; | ||
@@ -94,27 +94,14 @@ | ||
function guid() { | ||
return 'xxxxxxxx'.replace(/[xy]/g, function (c) { | ||
// eslint-disable-next-line no-bitwise | ||
var r = Math.random() * 16 | 0; // eslint-disable-next-line no-bitwise | ||
var v = c === 'x' ? r : r & 0x3 | 0x8; | ||
return v.toString(16); | ||
}); | ||
} | ||
var getKeyByPath = function getKeyByPath(item) { | ||
var path = item.path; | ||
if (path && path !== '/') { | ||
return path; | ||
} // 如果还是没有,用对象的hash 生成一个 | ||
if (!path || path === '/') { | ||
// 如果还是没有,用对象的hash 生成一个 | ||
try { | ||
return "/".concat(_hash.default.sha256().update(JSON.stringify(item)).digest('hex')); | ||
} catch (error) {// dom some thing | ||
} | ||
} | ||
try { | ||
return "/".concat(_hash.default.sha256().update(JSON.stringify(item)).digest('hex')); | ||
} catch (error) {// dom some thing | ||
} // 要是还是不行,返回一个随机值 | ||
return guid(); | ||
return path ? stripQueryStringAndHashFromPath(path) : path; | ||
}; | ||
@@ -249,3 +236,3 @@ /** | ||
}).filter(function (item) { | ||
var _item$menu, _item$menu2, _item$indexRoute, _item$indexRoute$menu, _item$indexRoute2, _item$indexRoute2$men; | ||
var _item$menu, _item$menu2; | ||
@@ -255,2 +242,3 @@ // 是否没有权限查看 | ||
if (item.unaccessible) { | ||
// eslint-disable-next-line no-param-reassign | ||
delete item.name; | ||
@@ -261,7 +249,2 @@ } | ||
return true; | ||
} // 兼容性,bigfish的兼容 | ||
if ((item === null || item === void 0 ? void 0 : (_item$indexRoute = item.indexRoute) === null || _item$indexRoute === void 0 ? void 0 : (_item$indexRoute$menu = _item$indexRoute.menu) === null || _item$indexRoute$menu === void 0 ? void 0 : _item$indexRoute$menu.name) || (item === null || item === void 0 ? void 0 : (_item$indexRoute2 = item.indexRoute) === null || _item$indexRoute2 === void 0 ? void 0 : (_item$indexRoute2$men = _item$indexRoute2.menu) === null || _item$indexRoute2$men === void 0 ? void 0 : _item$indexRoute2$men.flatMenu)) { | ||
return true; | ||
} // 显示指定在 menu 中隐藏该项 | ||
@@ -280,3 +263,3 @@ // layout 插件的功能,其实不应该存在的 | ||
}; | ||
var path = stripQueryStringAndHashFromPath(mergePath(item.path, parent ? parent.path : '/')); | ||
var path = mergePath(item.path, parent ? parent.path : '/'); | ||
var name = item.name; | ||
@@ -379,22 +362,29 @@ var locale = getItemLocaleName(item, parentName || 'menu'); // if enableMenuLocale use item.name, | ||
value: function get(pathname) { | ||
var routeValue; // eslint-disable-next-line no-restricted-syntax | ||
var routeValue; | ||
var _iterator = _createForOfIteratorHelper(this.entries()), | ||
_step; | ||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var _step$value = _slicedToArray(_step.value, 2), | ||
key = _step$value[0], | ||
value = _step$value[1]; | ||
// eslint-disable-next-line no-restricted-syntax | ||
var _iterator = _createForOfIteratorHelper(this.entries()), | ||
_step; | ||
if (!isUrl(key) && (0, _pathToRegexp.pathToRegexp)(key, []).test(pathname)) { | ||
routeValue = value; | ||
break; | ||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var _step$value = _slicedToArray(_step.value, 2), | ||
key = _step$value[0], | ||
value = _step$value[1]; | ||
var path = stripQueryStringAndHashFromPath(key); | ||
if (!isUrl(key) && (0, _pathToRegexp.pathToRegexp)(path, []).test(pathname)) { | ||
routeValue = value; | ||
break; | ||
} | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
} catch (error) { | ||
routeValue = undefined; | ||
} | ||
@@ -420,6 +410,2 @@ | ||
data.forEach(function (menuItem) { | ||
if (!menuItem) { | ||
return; | ||
} | ||
if (menuItem && menuItem.children) { | ||
@@ -431,3 +417,3 @@ flattenMenuData(menuItem.children, menuItem); | ||
var path = mergePath(menuItem.path, parent ? parent.path : '/'); | ||
routerMap.set(path, menuItem); | ||
routerMap.set(stripQueryStringAndHashFromPath(path), menuItem); | ||
}); | ||
@@ -434,0 +420,0 @@ }; |
{ | ||
"name": "@umijs/route-utils", | ||
"version": "1.0.30", | ||
"version": "1.0.31", | ||
"description": "Quickly process the routing of umi", | ||
@@ -21,3 +21,3 @@ "main": "lib/index.js", | ||
"test": "umi-test", | ||
"test:coverage": "umi-test ./src --coverage", | ||
"test:coverage": "umi-test ./test --coverage", | ||
"lint": "npm run lint-eslint", | ||
@@ -24,0 +24,0 @@ "lint-eslint": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src", |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
82368
28
1401
1