fix: 保留颜色匹配页面返回状态 (#294)
This commit is contained in:
@@ -45,3 +45,28 @@ func TestColorMappingTemplate_渲染分组候选安全表单和独立脚本(t *t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestShopeeListTemplate_颜色匹配入口只编码一次返回地址(t *testing.T) {
|
||||||
|
tmpl, err := template.ParseFS(templateFS, "templates/*/*.html")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
var output bytes.Buffer
|
||||||
|
err = tmpl.ExecuteTemplate(&output, "shopee/list", map[string]any{
|
||||||
|
"Title": "蝦皮数据", "Active": "shopee", "CSRFToken": "csrf-test",
|
||||||
|
"CurrentUser": &model.User{UserID: "U-1", Username: "buyer", Role: model.RolePurchaser},
|
||||||
|
"Rows": []service.ShopeeProductView{{GoodsID: "S-1", Title: "商品"}},
|
||||||
|
"ReturnTo": "/shopee?q=衣服&page=2", "CurrentPage": 2, "CurrentPageSize": 100,
|
||||||
|
"Status": "共 1 个商品", "DetailURL": "/shopee/detail?",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
html := strings.ToLower(output.String())
|
||||||
|
if !strings.Contains(html, "return_to=%2fshopee%3fq%3d") {
|
||||||
|
t.Fatalf("颜色匹配入口没有正确编码返回地址")
|
||||||
|
}
|
||||||
|
if strings.Contains(html, "return_to=%252fshopee") {
|
||||||
|
t.Fatal("返回地址被重复编码")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ func (h *Handler) renderShopeeList(c *gin.Context, keyword, searchFieldRaw, stat
|
|||||||
"DetailURL": "/shopee/detail?" + detailValuesForShopee(values, result.Page),
|
"DetailURL": "/shopee/detail?" + detailValuesForShopee(values, result.Page),
|
||||||
"AutoOpenDetailID": strings.TrimSpace(c.Query("open_id")),
|
"AutoOpenDetailID": strings.TrimSpace(c.Query("open_id")),
|
||||||
"AssignableClients": assignableClients,
|
"AssignableClients": assignableClients,
|
||||||
"ReturnToEscaped": url.QueryEscape(c.Request.URL.RequestURI()),
|
"ReturnTo": c.Request.URL.RequestURI(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@
|
|||||||
<td>{{.SourceText}}</td>
|
<td>{{.SourceText}}</td>
|
||||||
<td{{if .PddMissing}} class="missing"{{end}}>{{if .PddMissing}}未填写{{else}}<span title="{{.PddURL}}">{{.PddGoodsID}}</span>{{end}}</td>
|
<td{{if .PddMissing}} class="missing"{{end}}>{{if .PddMissing}}未填写{{else}}<span title="{{.PddURL}}">{{.PddGoodsID}}</span>{{end}}</td>
|
||||||
<td>{{.StatusText}}</td>
|
<td>{{.StatusText}}</td>
|
||||||
<td><a href="/shopee/color-mappings?goods_id={{.GoodsID}}&return_to={{$.ReturnToEscaped}}">进入匹配</a></td>
|
<td><a href="/shopee/color-mappings?goods_id={{.GoodsID}}&return_to={{$.ReturnTo}}">进入匹配</a></td>
|
||||||
<td>{{.UpdatedAt}}</td>
|
<td>{{.UpdatedAt}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|||||||
Reference in New Issue
Block a user