mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
perf: Cross-domain settings - Regex validation rule error
This commit is contained in:
@@ -199,7 +199,24 @@ const search = () => {
|
||||
}
|
||||
|
||||
const termFormRef = ref()
|
||||
|
||||
const validateUrl = (_: any, value: any, callback: any) => {
|
||||
if (value === '') {
|
||||
callback(
|
||||
new Error(
|
||||
t('datasource.please_enter') + t('common.empty') + t('embedded.cross_domain_settings')
|
||||
)
|
||||
)
|
||||
} else {
|
||||
// var Expression = /(https?:\/\/)?([\da-z\.-]+)\.([a-z]{2,6})(:\d{1,5})?([\/\w\.-]*)*\/?(#[\S]+)?/ // eslint-disable-line
|
||||
var Expression = /^https?:\/\/[^\s/?#]+(:\d+)?/i
|
||||
var objExp = new RegExp(Expression)
|
||||
if (objExp.test(value) && !value.endsWith('/')) {
|
||||
callback()
|
||||
} else {
|
||||
callback(t('embedded.format_is_incorrect'))
|
||||
}
|
||||
}
|
||||
}
|
||||
const rules = {
|
||||
name: [
|
||||
{
|
||||
@@ -210,8 +227,8 @@ const rules = {
|
||||
domain: [
|
||||
{
|
||||
required: true,
|
||||
message:
|
||||
t('datasource.please_enter') + t('common.empty') + t('embedded.cross_domain_settings'),
|
||||
validator: validateUrl,
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
@@ -258,7 +258,8 @@ const validateUrl = (_: any, value: any, callback: any) => {
|
||||
)
|
||||
)
|
||||
} else {
|
||||
var Expression = /(https?:\/\/)?([\da-z\.-]+)\.([a-z]{2,6})(:\d{1,5})?([\/\w\.-]*)*\/?(#[\S]+)?/ // eslint-disable-line
|
||||
// var Expression = /(https?:\/\/)?([\da-z\.-]+)\.([a-z]{2,6})(:\d{1,5})?([\/\w\.-]*)*\/?(#[\S]+)?/ // eslint-disable-line
|
||||
var Expression = /^https?:\/\/[^\s/?#]+(:\d+)?/i
|
||||
var objExp = new RegExp(Expression)
|
||||
if (objExp.test(value) && !value.endsWith('/')) {
|
||||
callback()
|
||||
|
||||
Reference in New Issue
Block a user