优化内链域名特殊字符替换

This commit is contained in:
RuoYi 2021-12-01 08:39:53 +08:00
parent 9e9e171338
commit 19655fe366

View File

@ -179,7 +179,7 @@ public class SysMenuServiceImpl implements ISysMenuService
router.setPath("/inner"); router.setPath("/inner");
List<RouterVo> childrenList = new ArrayList<RouterVo>(); List<RouterVo> childrenList = new ArrayList<RouterVo>();
RouterVo children = new RouterVo(); RouterVo children = new RouterVo();
String routerPath = StringUtils.replaceEach(menu.getPath(), new String[] { Constants.HTTP, Constants.HTTPS }, new String[] { "", "" }); String routerPath = innerLinkReplaceEach(menu.getPath());
children.setPath(routerPath); children.setPath(routerPath);
children.setComponent(UserConstants.INNER_LINK); children.setComponent(UserConstants.INNER_LINK);
children.setName(StringUtils.capitalize(routerPath)); children.setName(StringUtils.capitalize(routerPath));
@ -358,7 +358,7 @@ public class SysMenuServiceImpl implements ISysMenuService
// 内链打开外网方式 // 内链打开外网方式
if (menu.getParentId().intValue() != 0 && isInnerLink(menu)) if (menu.getParentId().intValue() != 0 && isInnerLink(menu))
{ {
routerPath = StringUtils.replaceEach(routerPath, new String[] { Constants.HTTP, Constants.HTTPS }, new String[] { "", "" }); routerPath = innerLinkReplaceEach(routerPath);
} }
// 非外链并且是一级目录类型为目录 // 非外链并且是一级目录类型为目录
if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType()) if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType())
@ -500,4 +500,15 @@ public class SysMenuServiceImpl implements ISysMenuService
{ {
return getChildList(list, t).size() > 0 ? true : false; return getChildList(list, t).size() > 0 ? true : false;
} }
/**
* 内链域名特殊字符替换
*
* @return
*/
public String innerLinkReplaceEach(String path)
{
return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS },
new String[] { "", "" });
}
} }