[frontend-gray] support grayKey from localStorage (#1395)

This commit is contained in:
mamba
2024-10-18 13:58:52 +08:00
committed by GitHub
parent c67f494b49
commit 11ff2d1d31
6 changed files with 115 additions and 43 deletions

View File

@@ -53,6 +53,30 @@ func TestIndexRewrite(t *testing.T) {
}
}
func TestIndexRewrite2(t *testing.T) {
matchRules := map[string]string{
"/": "/{version}/index.html",
"/sta": "/sta/{version}/index.html",
"/static": "/static/{version}/index.html",
}
var tests = []struct {
path, output string
}{
{"/static123", "/static/v1.0.0/index.html"},
{"/static", "/static/v1.0.0/index.html"},
{"/sta", "/sta/v1.0.0/index.html"},
{"/", "/v1.0.0/index.html"},
}
for _, test := range tests {
testName := test.path
t.Run(testName, func(t *testing.T) {
output := IndexRewrite(testName, "v1.0.0", matchRules)
assert.Equal(t, test.output, output)
})
}
}
func TestPrefixFileRewrite(t *testing.T) {
matchRules := map[string]string{
// 前缀匹配