mirror of
https://gitee.com/mirrors/AllinSSL.git
synced 2026-03-08 07:41:10 +08:00
【优化】更新域名验证逻辑,新增isDomainOrWildcardDomain函数,提升域名格式校验的准确性。
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { FormRules } from 'naive-ui'
|
||||
import { $t } from '@locales/index'
|
||||
import { createNodeValidator } from '@workflowView/lib/NodeValidator'
|
||||
import { isDomain, isWildcardDomain } from '@baota/utils/business'
|
||||
import { isDomainOrWildcardDomain } from '@baota/utils/business'
|
||||
|
||||
// 创建部署节点验证器
|
||||
const validator = createNodeValidator($t('t_11_1747817612051'))
|
||||
@@ -51,8 +51,9 @@ export default {
|
||||
if (!value) {
|
||||
return new Error($t('t_0_1744958839535'))
|
||||
}
|
||||
if (!isWildcardDomain(value)) {
|
||||
return new Error($t('t_0_1744958839535'))
|
||||
|
||||
if (!isDomainOrWildcardDomain(value)) {
|
||||
return new Error($t('域名格式错误'))
|
||||
}
|
||||
return true
|
||||
}, 'input'),
|
||||
|
||||
@@ -160,6 +160,13 @@ export const isEnhancedDomain = R.test(ENHANCED_DOMAIN_REGEX)
|
||||
*/
|
||||
export const isWildcardDomain = R.test(WILDCARD_DOMAIN_REGEX)
|
||||
|
||||
/**
|
||||
* 判断是否为域名或通配符域名
|
||||
* @param {string} domain - 要判断的域名
|
||||
* @returns {boolean} 如果域名或通配符域名是有效的,则返回 true,否则返回 false
|
||||
*/
|
||||
export const isDomainOrWildcardDomain = (domain: string): boolean => isDomain(domain) || isWildcardDomain(domain)
|
||||
|
||||
/**
|
||||
* 判断域名组,通过特定字符串分割
|
||||
* @param {string} domain - 要判断的域名
|
||||
|
||||
Reference in New Issue
Block a user