From 699cae9647670b860a357bb2d1626a0df49f880b Mon Sep 17 00:00:00 2001 From: HynoR <20227709+HynoR@users.noreply.github.com> Date: Thu, 12 Feb 2026 11:27:37 +0800 Subject: [PATCH 1/2] feat: Enhance domain handling in website creation --- .../views/website/website/create/index.vue | 25 +++++++++++++------ .../website/website/domain-create/index.vue | 22 +++++++++++----- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/frontend/src/views/website/website/create/index.vue b/frontend/src/views/website/website/create/index.vue index f9a4403e08a5..ee01bdf3e8c9 100644 --- a/frontend/src/views/website/website/create/index.vue +++ b/frontend/src/views/website/website/create/index.vue @@ -192,7 +192,11 @@
- +
{{ $t('website.advancedSettings') }} @@ -1003,11 +1007,7 @@ const submit = async (formEl: FormInstance | undefined) => { watch( () => website.value.domains, - (value) => { - if (value && value.length > 0) { - const firstDomain = value[0].domain; - changeAlias(firstDomain); - } + () => { tryAutoSelectSSL(); }, { deep: true }, @@ -1042,7 +1042,18 @@ watch( { deep: true }, ); -const changeAlias = (value: string) => { +const handleFirstDomainBlur = (index: number) => { + if (index !== 0) { + return; + } + const firstDomain = website.value.domains?.[0]?.domain || ''; + fillAliasFromDomainIfEmpty(firstDomain); +}; + +const fillAliasFromDomainIfEmpty = (value: string) => { + if (!value || website.value.alias.trim() !== '') { + return; + } const domain = value.split(':')[0]; website.value.alias = domain; }; diff --git a/frontend/src/views/website/website/domain-create/index.vue b/frontend/src/views/website/website/domain-create/index.vue index 9668ffbc502a..f372fe1039af 100644 --- a/frontend/src/views/website/website/domain-create/index.vue +++ b/frontend/src/views/website/website/domain-create/index.vue @@ -83,6 +83,7 @@ import { checkAppInstalled } from '@/api/modules/app'; import { Rules, checkNumberRange } from '@/global/form-rules'; import { MsgError } from '@/utils/message'; +import { toASCII } from 'punycode'; import { ref, onMounted, nextTick } from 'vue'; import { useI18n } from 'vue-i18n'; @@ -97,7 +98,7 @@ const props = defineProps({ }, }); -const emit = defineEmits(['gengerate']); +const emit = defineEmits(['gengerate', 'domain-blur']); const ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; @@ -128,17 +129,22 @@ function toPunycode(hostname: string): string { return hostname; } + const convertLabels = (value: string): string => { + return value + .split('.') + .map((label) => (label === '*' || label === '' ? label : toASCII(label))) + .join('.'); + }; + if (hostname.startsWith('*.')) { const domainPart = hostname.substring(2); - const convertedDomain = new URL(`http://${domainPart}`).hostname; - return `*.${convertedDomain}`; + return `*.${convertLabels(domainPart)}`; } if (hostname.endsWith('.*')) { const domainPart = hostname.slice(0, -2); - const convertedDomain = new URL(`http://${domainPart}`).hostname; - return `${convertedDomain}.*`; + return `${convertLabels(domainPart)}.*`; } - return new URL(`http://${hostname}`).hostname; + return convertLabels(hostname); } catch { return hostname; } @@ -149,6 +155,7 @@ const handleDomainBlur = (index: number) => { if (!originalDomain) { create.value.domains[index].host = ''; domainWarnings.value[index] = false; + emit('domain-blur', index); return; } @@ -157,12 +164,14 @@ const handleDomainBlur = (index: number) => { create.value.domains[index].host = originalDomain; create.value.domains[index].domain = originalDomain; domainWarnings.value[index] = false; + emit('domain-blur', index); return; } let singleRegexChecked = singleDomainRegex.test(originalDomain); if (!singleRegexChecked) { domainWarnings.value[index] = false; + emit('domain-blur', index); return; } @@ -179,6 +188,7 @@ const handleDomainBlur = (index: number) => { } else { domainWarnings.value[index] = false; } + emit('domain-blur', index); }; const validateSingleDomain = (_rule: any, value: string, callback: (error?: Error) => void) => { From 0e35e56883f9bc3b829544890c0435f52079206f Mon Sep 17 00:00:00 2001 From: HynoR <20227709+HynoR@users.noreply.github.com> Date: Thu, 12 Feb 2026 12:36:19 +0800 Subject: [PATCH 2/2] fix: Improve domain trimming and validation in website alias assignment --- frontend/src/views/website/website/create/index.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/website/website/create/index.vue b/frontend/src/views/website/website/create/index.vue index ee01bdf3e8c9..1434e6979c36 100644 --- a/frontend/src/views/website/website/create/index.vue +++ b/frontend/src/views/website/website/create/index.vue @@ -1054,7 +1054,10 @@ const fillAliasFromDomainIfEmpty = (value: string) => { if (!value || website.value.alias.trim() !== '') { return; } - const domain = value.split(':')[0]; + const domain = value.split(':')[0].trim(); + if (!domain) { + return; + } website.value.alias = domain; };