mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-15 21:20:25 +08:00
URL跳转之域名跳转增加跳转后域名校验
This commit is contained in:
@@ -3,6 +3,7 @@ package redirects
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dns/domains/domainutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
@@ -134,6 +135,23 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
this.FailField("domainAfter", "请输入跳转后域名")
|
this.FailField("domainAfter", "请输入跳转后域名")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查用户输入的是否为域名
|
||||||
|
if !domainutils.ValidateDomainFormat(params.DomainAfter) {
|
||||||
|
// 是否为URL
|
||||||
|
u, err := url.Parse(params.DomainAfter)
|
||||||
|
if err == nil {
|
||||||
|
if len(u.Host) == 0 {
|
||||||
|
this.FailField("domainAfter", "跳转后域名输入不正确")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
params.DomainAfter = u.Host
|
||||||
|
} else {
|
||||||
|
this.FailField("domainAfter", "跳转后域名输入不正确")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
config.DomainAfter = params.DomainAfter
|
config.DomainAfter = params.DomainAfter
|
||||||
config.DomainAfterScheme = params.DomainAfterScheme
|
config.DomainAfterScheme = params.DomainAfterScheme
|
||||||
case serverconfigs.HTTPHostRedirectTypePort:
|
case serverconfigs.HTTPHostRedirectTypePort:
|
||||||
|
|||||||
@@ -90,7 +90,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="color-border">跳转后域名 *</td>
|
<td class="color-border">跳转后域名 *</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="domainAfter" maxlength="100" v-model="redirect.domainAfter"/>
|
<input type="text" name="domainAfter" maxlength="100" v-model="redirect.domainAfter" placeholder="比如example.com"/>
|
||||||
|
<p class="comment">这里填写的是网址中的域名部分,不需要添加<code-label>https://</code-label>部分。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user