update
This commit is contained in:
@ -10,7 +10,7 @@ import (
|
||||
// - 查询串模式(style 含 =):base_url/key?w=..&q=..
|
||||
// - /uploads/ 与 http(s) 原样返回
|
||||
func TestDisplayStyle(t *testing.T) {
|
||||
c := New("https://mybucket.s3.bitiful.net", "high", "thumb", "")
|
||||
c := New("https://mybucket.s3.bitiful.net", "high", "thumb")
|
||||
got := c.Compose("runway/abc123.jpg")
|
||||
want := "https://mybucket.s3.bitiful.net/runway/abc123.jpg!style:high"
|
||||
if got != want {
|
||||
@ -18,13 +18,13 @@ func TestDisplayStyle(t *testing.T) {
|
||||
}
|
||||
|
||||
// 缺省回落 high
|
||||
c0 := New("https://mybucket.s3.bitiful.net", "", "", "")
|
||||
c0 := New("https://mybucket.s3.bitiful.net", "", "")
|
||||
if c0.Compose("runway/abc123.jpg") != "https://mybucket.s3.bitiful.net/runway/abc123.jpg!style:high" {
|
||||
t.Fatal("style 缺省应回落 high")
|
||||
}
|
||||
|
||||
// 查询串模式
|
||||
cq := New("https://mybucket.s3.bitiful.net", "w=1080&q=80&fmt=webp", "", "")
|
||||
cq := New("https://mybucket.s3.bitiful.net", "w=1080&q=80&fmt=webp", "")
|
||||
gq := cq.Compose("runway/abc123.jpg")
|
||||
wq := "https://mybucket.s3.bitiful.net/runway/abc123.jpg?w=1080&q=80&fmt=webp"
|
||||
if gq != wq {
|
||||
@ -45,7 +45,7 @@ func TestDisplayStyle(t *testing.T) {
|
||||
|
||||
// TestComposeThumb 验证列表缩略图拼装:走 StyleThumb,兜底逻辑与 Compose 一致。
|
||||
func TestComposeThumb(t *testing.T) {
|
||||
c := New("https://mybucket.s3.bitiful.net", "high", "thumb", "")
|
||||
c := New("https://mybucket.s3.bitiful.net", "high", "thumb")
|
||||
got := c.ComposeThumb("runway/abc123.jpg")
|
||||
want := "https://mybucket.s3.bitiful.net/runway/abc123.jpg!style:thumb"
|
||||
if got != want {
|
||||
@ -53,7 +53,7 @@ func TestComposeThumb(t *testing.T) {
|
||||
}
|
||||
|
||||
// 未配置 styleThumb 时应回落展示样式,不得拼出空样式(key!style:)
|
||||
c0 := New("https://mybucket.s3.bitiful.net", "high", "", "")
|
||||
c0 := New("https://mybucket.s3.bitiful.net", "high", "")
|
||||
if got := c0.ComposeThumb("runway/abc123.jpg"); got != "https://mybucket.s3.bitiful.net/runway/abc123.jpg!style:high" {
|
||||
t.Fatalf("styleThumb 缺省应回落 styleDisplay,实际 %s", got)
|
||||
}
|
||||
@ -72,7 +72,7 @@ func TestComposeThumb(t *testing.T) {
|
||||
|
||||
// TestDisplayStyleURLSafe 确认展示 URL 不含任何签名/过期参数(匿名可访问)。
|
||||
func TestDisplayStyleURLSafe(t *testing.T) {
|
||||
c := New("https://mybucket.s3.bitiful.net", "high", "thumb", "")
|
||||
c := New("https://mybucket.s3.bitiful.net", "high", "thumb")
|
||||
u := c.Compose("runway/abc123.jpg")
|
||||
for _, bad := range []string{"X-Amz", "sign", "e="} {
|
||||
if strings.Contains(u, bad) {
|
||||
|
||||
Reference in New Issue
Block a user