File tree Expand file tree Collapse file tree 1 file changed +9
-18
lines changed
Expand file tree Collapse file tree 1 file changed +9
-18
lines changed Original file line number Diff line number Diff line change @@ -59,26 +59,17 @@ func normalizeCommandLine(commandLine string) (string, error) {
5959 return "" , fmt .Errorf ("解析查询参数失败: %w" , err )
6060 }
6161
62- // 获取所有的参数键并排序
63- keys := make ([]string , 0 , len (values ))
64- for k := range values {
65- keys = append (keys , k )
62+ // 使用 Encode() 方法重建查询参数
63+ // Encode() 会自动:
64+ // 1. 按字母顺序排序键
65+ // 2. 正确处理 URL 编码
66+ // 3. 正确处理裸键和多值参数
67+ encoded := values .Encode ()
68+ if encoded == "" {
69+ return base , nil
6670 }
67- sort .Strings (keys )
6871
69- // 按排序后的顺序重建查询参数
70- params := make ([]string , 0 , len (keys ))
71- for _ , k := range keys {
72- for _ , v := range values [k ] {
73- params = append (params , fmt .Sprintf ("%s=%s" , k , v ))
74- }
75- }
76-
77- // 重建完整的 commandLine
78- if len (params ) > 0 {
79- return base + "?" + strings .Join (params , "&" ), nil
80- }
81- return base , nil
72+ return base + "?" + encoded , nil
8273}
8374
8475// setupTunnelRoutes 设置隧道相关路由
You can’t perform that action at this time.
0 commit comments