Skip to content

Commit 721e370

Browse files
feat: add domain validate for appinstall webUI (#8939)
Refs #8936
1 parent 349c97f commit 721e370

File tree

1 file changed

+31
-2
lines changed
  • frontend/src/views/app-store/installed/detail

1 file changed

+31
-2
lines changed

frontend/src/views/app-store/installed/detail/index.vue

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ import { getAppInstallParams, updateAppInstallParams, updateInstallConfig } from
130130
import { reactive, ref } from 'vue';
131131
import { FormInstance } from 'element-plus';
132132
import { Rules, checkNumberRange } from '@/global/form-rules';
133-
import { MsgSuccess } from '@/utils/message';
134-
import { getLabel, splitHttp } from '@/utils/util';
133+
import { MsgError, MsgSuccess } from '@/utils/message';
134+
import { getLabel, splitHttp, checkIpV4V6, checkDomain } from '@/utils/util';
135135
import i18n from '@/lang';
136136
137137
interface ParamProps {
@@ -176,6 +176,31 @@ const webUI = reactive({
176176
domain: '',
177177
});
178178
179+
function checkWebUI() {
180+
if (webUI.domain !== '') {
181+
let domain = webUI.domain;
182+
let port = null;
183+
if (domain.includes(':')) {
184+
const parts = domain.split(':');
185+
domain = parts[0];
186+
port = parts[1];
187+
188+
if (!checkPort(port)) {
189+
return false;
190+
}
191+
}
192+
if (checkIpV4V6(domain) && checkDomain(domain)) {
193+
return false;
194+
}
195+
}
196+
return true;
197+
}
198+
199+
function checkPort(port: string) {
200+
const portNum = parseInt(port, 10);
201+
return !isNaN(portNum) && portNum > 0 && portNum <= 65535;
202+
}
203+
179204
const acceptParams = async (props: ParamProps) => {
180205
submitModel.value.installId = props.id;
181206
params.value = [];
@@ -297,6 +322,10 @@ const updateAppConfig = async () => {
297322
if (!webUI.domain || webUI.domain === '') {
298323
req.webUI = '';
299324
}
325+
if (!checkWebUI()) {
326+
MsgError(i18n.global.t('commons.rule.host'));
327+
return;
328+
}
300329
await updateInstallConfig(req);
301330
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
302331
handleClose();

0 commit comments

Comments
 (0)