fix: 修复1:: 形式的ipv6校验失败的bug

This commit is contained in:
xiaojunnuo
2026-01-31 02:07:06 +08:00
parent 52cbff0e15
commit 8b96f218d5
6 changed files with 37 additions and 12 deletions

View File

@@ -58,8 +58,13 @@ function isIpv6(d: string) {
if (!d) {
return false;
}
const isIPv6Regex = /^([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4})$/gm;
return isIPv6Regex.test(d);
try {
// 尝试构造URL用IPv6作为hostname
new URL(`http://[${d}]`);
return true;
} catch {
return false;
}
}
function isIp(d: string) {

View File

@@ -60,6 +60,7 @@ import { request } from "/@/api/service";
import { Dicts } from "../lib/dicts";
import { useRouter } from "vue-router";
import { useDomainImport, useDomainImportManage } from "/@/views/certd/cert/domain/use";
import { openRouteInNewWindow } from "/@/vben/utils";
defineOptions({
name: "DomainSelector",
@@ -190,7 +191,7 @@ const router = useRouter();
function openDomainManager(e: any) {
e.preventDefault();
// router.push("/certd/cert/domain");
window.open(`${window.location.origin}/#/certd/cert/domain`);
openRouteInNewWindow("/certd/cert/domain");
}
const openDomainImportManageDialog = useDomainImportManage();

View File

@@ -4,8 +4,16 @@ function isIpv6(d: string) {
if (!d) {
return false;
}
const isIPv6Regex = /^([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4})$/gm;
return isIPv6Regex.test(d);
// const isIPv6Regex = /^([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4})$/gm;
// return isIPv6Regex.test(d);
try {
// 尝试构造URL用IPv6作为hostname
new URL(`http://[${d}]`);
return true;
} catch {
return false;
}
}
function isIpv4(d: string) {
if (!d) {

View File

@@ -167,7 +167,6 @@ function useMixedMenu() {
* @param path 路由路径
*/
function calcSideMenus(path: string = route.path) {
debugger;
let { rootMenu } = findRootMenuByPath(menus.value, path);
if (!rootMenu) {
rootMenu = menus.value.find((item: any) => item.path === path);

View File

@@ -27,8 +27,12 @@ function openWindow(url: string, options: OpenWindowOptions = {}): void {
*/
function openRouteInNewWindow(path: string) {
const { hash, origin } = location;
let pathname = location.pathname;
if (pathname.endsWith("/")) {
pathname = pathname.slice(0, -1);
}
const fullPath = path.startsWith("/") ? path : `/${path}`;
const url = `${origin}${hash ? "/#" : ""}${fullPath}`;
const url = `${origin}${pathname}${hash ? "/#" : ""}${fullPath}`;
openWindow(url, { target: "_blank" });
}

View File

@@ -19,15 +19,16 @@ process.env.VITE_APP_VERSION = require("./package.json").version;
process.env.VITE_APP_BUILD_TIME = require("dayjs")().format("YYYY-M-D HH:mm:ss");
import * as https from "node:https";
export default ({ command, mode }) => {
export default (req: any) => {
const { command, mode } = req;
console.log("args", command, mode);
const env = loadEnv(mode, process.cwd());
const devServerFs: any = {};
const devAlias: any[] = [];
const base = "./";
// if (mode.startsWith("dev")) {
// base = "./";
// }
let base = "./";
if (mode.startsWith("dev")) {
base = "/certd";
}
return {
base: base,
plugins: [
@@ -96,6 +97,13 @@ export default ({ command, mode }) => {
//忽略证书
agent: new https.Agent({ rejectUnauthorized: false }),
},
"/certd/api": {
//配套后端 https://github.com/fast-crud/fs-server-js
target: "https://127.0.0.1:7002/api",
rewrite: path => path.replace(/^\/certd\/api/, ""),
//忽略证书
agent: new https.Agent({ rejectUnauthorized: false }),
},
},
},
};