mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 07:40:56 +08:00 
			
		
		
		
	修复合并URL中多余分隔符时导致参数发生变化的Bug
This commit is contained in:
		@@ -9,6 +9,10 @@ func CleanPath(path string) string {
 | 
			
		||||
	result := []byte{'/'}
 | 
			
		||||
	isSlash := true
 | 
			
		||||
	for i := 0; i < l; i++ {
 | 
			
		||||
		if path[i] == '?' {
 | 
			
		||||
			result = append(result, path[i:]...)
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
		if path[i] == '\\' || path[i] == '/' {
 | 
			
		||||
			if !isSlash {
 | 
			
		||||
				isSlash = true
 | 
			
		||||
@@ -21,4 +25,3 @@ func CleanPath(path string) string {
 | 
			
		||||
	}
 | 
			
		||||
	return string(result)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,11 @@ func TestCleanPath(t *testing.T) {
 | 
			
		||||
	a.IsTrue(CleanPath("/hello////world") == "/hello/world")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestCleanPath_Args(t *testing.T) {
 | 
			
		||||
	a := assert.NewAssertion(t)
 | 
			
		||||
	a.IsTrue(CleanPath("/hello/world?base=///////") == "/hello/world?base=///////")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func BenchmarkCleanPath(b *testing.B) {
 | 
			
		||||
	for i := 0; i < b.N; i++ {
 | 
			
		||||
		_ = CleanPath("/hello///world/very/long/very//long")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user