mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 16:00:25 +08:00 
			
		
		
		
	服务增加是否合并URL中的多余分隔符选项
This commit is contained in:
		@@ -86,13 +86,21 @@ type HTTPRequest struct {
 | 
			
		||||
// 初始化
 | 
			
		||||
func (this *HTTPRequest) init() {
 | 
			
		||||
	this.writer = NewHTTPWriter(this, this.RawWriter)
 | 
			
		||||
	this.web = &serverconfigs.HTTPWebConfig{IsOn: true}
 | 
			
		||||
	this.web = &serverconfigs.HTTPWebConfig{
 | 
			
		||||
		IsOn: true,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// this.uri = this.RawReq.URL.RequestURI()
 | 
			
		||||
	// 之所以不使用RequestURI(),是不想让URL中的Path被Encode
 | 
			
		||||
	var urlPath = this.RawReq.URL.Path
 | 
			
		||||
	if this.Server.Web != nil && this.Server.Web.MergeSlashes {
 | 
			
		||||
		urlPath = utils.CleanPath(urlPath)
 | 
			
		||||
		this.web.MergeSlashes = true
 | 
			
		||||
	}
 | 
			
		||||
	if len(this.RawReq.URL.RawQuery) > 0 {
 | 
			
		||||
		this.uri = this.RawReq.URL.Path + "?" + this.RawReq.URL.RawQuery
 | 
			
		||||
		this.uri = urlPath + "?" + this.RawReq.URL.RawQuery
 | 
			
		||||
	} else {
 | 
			
		||||
		this.uri = this.RawReq.URL.Path
 | 
			
		||||
		this.uri = urlPath
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	this.rawURI = this.uri
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
package nodes
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/TeaOSLab/EdgeNode/internal/utils"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
@@ -8,7 +9,11 @@ import (
 | 
			
		||||
 | 
			
		||||
// 主机地址快速跳转
 | 
			
		||||
func (this *HTTPRequest) doHostRedirect() (blocked bool) {
 | 
			
		||||
	fullURL := this.requestScheme() + "://" + this.Host + this.RawReq.URL.Path
 | 
			
		||||
	var urlPath = this.RawReq.URL.Path
 | 
			
		||||
	if this.web.MergeSlashes {
 | 
			
		||||
		urlPath = utils.CleanPath(urlPath)
 | 
			
		||||
	}
 | 
			
		||||
	fullURL := this.requestScheme() + "://" + this.Host + urlPath
 | 
			
		||||
	for _, u := range this.web.HostRedirects {
 | 
			
		||||
		if !u.IsOn {
 | 
			
		||||
			continue
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
package utils
 | 
			
		||||
 | 
			
		||||
// 清理Path中的多余的字符
 | 
			
		||||
// CleanPath 清理Path中的多余的字符
 | 
			
		||||
func CleanPath(path string) string {
 | 
			
		||||
	l := len(path)
 | 
			
		||||
	if l == 0 {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user