Skip to content

Commit 11764e1

Browse files
authored
feat: improve website create function and interface (#11331)
* feat: improve website create function and interface * feat: update website create tag * feat: update i18n files * feat: update valid domain regex * feat: reorder website types to improve structure * feat: update domain labels for consistency in the domain creation form * feat: update i18n
1 parent 3212e23 commit 11764e1

File tree

16 files changed

+324
-132
lines changed

16 files changed

+324
-132
lines changed

agent/app/service/website_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ func getWebsiteDomains(domains []request.WebsiteDomain, defaultHTTPPort, default
11071107
if domain.Domain == "" {
11081108
continue
11091109
}
1110-
if !common.IsValidDomain(domain.Domain) {
1110+
if !common.IsValidNginxServerName(domain.Domain) {
11111111
err = buserr.WithName("ErrDomainFormat", domain.Domain)
11121112
return
11131113
}

agent/utils/common/common.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ func IsValidDomain(domain string) bool {
306306
return re.GetRegex(re.DomainPattern).MatchString(domain)
307307
}
308308

309+
func IsValidNginxServerName(serverName string) bool {
310+
return re.GetRegex(re.NginxServerNamePattern).MatchString(serverName)
311+
}
312+
309313
func ContainsChinese(text string) bool {
310314
for _, char := range text {
311315
if unicode.Is(unicode.Han, char) {

agent/utils/re/re.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const (
1414
ValidatorNamePattern = `^[a-zA-Z\p{Han}]{1}[a-zA-Z0-9_\p{Han}]{0,30}$`
1515
ValidatorIPPattern = `^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$`
1616
DomainPattern = `^([\w\p{Han}\-\*]{1,100}\.){1,10}([\w\p{Han}\-]{1,24}|[\w\p{Han}\-]{1,24}\.[\w\p{Han}\-]{1,24})(:\d{1,5})?$`
17+
NginxServerNamePattern = `^(?:\*|[\w\p{Han}-]{1,63})(?:\.(?:\*|[\w\p{Han}-]{1,63}))*$`
1718
ProxyCacheZonePattern = `keys_zone=proxy_cache_zone_of_[\w.]+:(\d+)([kmgt]?)`
1819
ProxyCacheMaxSizePattern = `max_size=([0-9.]+)([kmgt]?)`
1920
ProxyCacheMaxSizeValidationPattern = `max_size=\d+(\.\d+)?[kmgt]?`
@@ -44,6 +45,7 @@ func Init() {
4445
ValidatorNamePattern,
4546
ValidatorIPPattern,
4647
DomainPattern,
48+
NginxServerNamePattern,
4749
ProxyCacheZonePattern,
4850
ProxyCacheMaxSizePattern,
4951
ProxyCacheMaxSizeValidationPattern,

frontend/src/global/mimetype.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,14 @@ export const getWebsiteTypes = () => [
458458
label: i18n.global.t('runtime.runtime'),
459459
value: 'runtime',
460460
},
461-
{
462-
label: i18n.global.t('website.proxy'),
463-
value: 'proxy',
464-
},
465461
{
466462
label: i18n.global.t('website.static'),
467463
value: 'static',
468464
},
465+
{
466+
label: i18n.global.t('website.proxy'),
467+
value: 'proxy',
468+
},
469469
{
470470
label: i18n.global.t('website.subsite'),
471471
value: 'subsite',

frontend/src/lang/modules/en.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,6 +2640,10 @@ const message = {
26402640
createDb: 'Create Database',
26412641
enableSSLHelper: 'Failure to enable will not affect the creation of the website',
26422642
batchAdd: 'Batch Add Domains',
2643+
batchInput: 'Batch Input',
2644+
domainNotFQDN: 'This domain may not be accessible on the public network',
2645+
domainInvalid: 'Invalid domain format',
2646+
domainBatchHelper: 'One domain per line, format: domain:port@ssl\nExample: example.com:443@ssl or example.com',
26432647
generateDomain: 'Generate',
26442648
global: 'Global',
26452649
subsite: 'Subsite',

frontend/src/lang/modules/es-es.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2632,6 +2632,11 @@ const message = {
26322632
createDb: 'Crear base de datos',
26332633
enableSSLHelper: 'Si falla, no afectará la creación del sitio',
26342634
batchAdd: 'Añadir múltiples dominios',
2635+
batchInput: 'Entrada por Lotes',
2636+
domainNotFQDN: 'Este dominio puede no ser accesible en la red pública',
2637+
domainInvalid: 'Formato de dominio inválido',
2638+
domainBatchHelper:
2639+
'Un dominio por línea, formato: dominio:puerto@ssl\nEjemplo: example.com:443@ssl o example.com',
26352640
generateDomain: 'Generar',
26362641
global: 'Global',
26372642
subsite: 'Subsitio',

frontend/src/lang/modules/ja.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2561,6 +2561,10 @@ const message = {
25612561
createDb: 'データベースを作成',
25622562
enableSSLHelper: 'SSLの有効化に失敗しても、ウェブサイトの作成には影響しません。',
25632563
batchAdd: 'ドメインを一括追加',
2564+
batchInput: 'バッチ入力',
2565+
domainNotFQDN: 'このドメインはパブリックネットワークからアクセスできない可能性があります',
2566+
domainInvalid: 'ドメイン形式が正しくありません',
2567+
domainBatchHelper: '1行に1ドメイン、形式: domain:port@ssl\n例: example.com:443@ssl または example.com',
25642568
generateDomain: '生成',
25652569
global: 'グローバル',
25662570
subsite: 'サブサイト',

frontend/src/lang/modules/ko.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,6 +2516,10 @@ const message = {
25162516
createDb: '데이터베이스 생성',
25172517
enableSSLHelper: 'SSL 활성화 실패는 웹사이트 생성에 영향을 미치지 않습니다.',
25182518
batchAdd: '도메인 일괄 추가',
2519+
batchInput: '일괄 입력',
2520+
domainNotFQDN: '이 도메인은 공용 네트워크에서 액세스할 수 없을 수 있습니다',
2521+
domainInvalid: '도메인 형식이 올바르지 않습니다',
2522+
domainBatchHelper: '한 줄에 하나의 도메인, 형식: domain:port@ssl\n예: example.com:443@ssl 또는 example.com',
25192523
generateDomain: '생성',
25202524
global: '글로벌',
25212525
subsite: '하위 사이트',

frontend/src/lang/modules/ms.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,11 @@ const message = {
26172617
createDb: 'Cipta Pangkalan Data',
26182618
enableSSLHelper: 'Kegagalan mengaktifkan SSL tidak akan menjejaskan penciptaan laman web.',
26192619
batchAdd: 'Tambah Domain Secara Batch',
2620+
batchInput: 'Input Kelompok',
2621+
domainNotFQDN: 'Domain ini mungkin tidak boleh diakses di rangkaian awam',
2622+
domainInvalid: 'Format domain tidak sah',
2623+
domainBatchHelper:
2624+
'Satu domain per baris, format: domain:port@ssl\nContoh: example.com:443@ssl atau example.com',
26202625
generateDomain: 'Hasilkan',
26212626
global: 'Global',
26222627
subsite: 'Sublaman',

frontend/src/lang/modules/pt-br.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,6 +2622,11 @@ const message = {
26222622
createDb: 'Criar Banco de Dados',
26232623
enableSSLHelper: 'A falha ao ativar o SSL não afetará a criação do site.',
26242624
batchAdd: 'Adicionar Domínios em Lote',
2625+
batchInput: 'Entrada em Lote',
2626+
domainNotFQDN: 'Este domínio pode não estar acessível na rede pública',
2627+
domainInvalid: 'Formato de domínio inválido',
2628+
domainBatchHelper:
2629+
'Um domínio por linha, formato: domínio:porta@ssl\nExemplo: example.com:443@ssl ou example.com',
26252630
generateDomain: 'Gerar',
26262631
global: 'Global',
26272632
subsite: 'Subsite',

0 commit comments

Comments
 (0)