fix: 🐛 frontend-grayurl 解析不正确导致路由失败 (#1550)

This commit is contained in:
mamba
2024-11-29 13:09:05 +08:00
committed by GitHub
parent bb64b43f23
commit 6187be97e5
2 changed files with 11 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ package main
import (
"fmt"
"net/http"
"net/url"
"path"
"strings"
@@ -35,6 +36,12 @@ func parseConfig(json gjson.Result, grayConfig *config.GrayConfig, log wrapper.L
func onHttpRequestHeaders(ctx wrapper.HttpContext, grayConfig config.GrayConfig, log wrapper.Log) types.Action {
requestPath, _ := proxywasm.GetHttpRequestHeader(":path")
requestPath = path.Clean(requestPath)
parsedURL, err := url.Parse(requestPath)
if err == nil {
requestPath = parsedURL.Path
} else {
log.Errorf("parse request path %s failed: %v", requestPath, err)
}
enabledGray := util.IsGrayEnabled(grayConfig, requestPath)
ctx.SetContext(config.EnabledGray, enabledGray)