8000 no url set cached url empty string by zhangshanwen · Pull Request #509 · qor5/admin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

no url set cached url empty string #509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion media/base/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ func (b Base) URL(styles ...string) string {
}

func (b Base) URLNoCached(styles ...string) string {
return b.URL(styles...) + "?" + fmt.Sprint(time.Now().Nanosecond())
i := b.URL(styles...)
if i != "" {
return i + "?" + fmt.Sprint(time.Now().Nanosecond())
}
return i
}

// String return file's url
Expand Down
10 changes: 10 additions & 0 deletions media/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,20 @@ func TestUnCachedURL(t *testing.T) {
t.Fatalf("set uncached url error %v", b.URLNoCached())
return
}
b.Url = ""
if b.URLNoCached() != "" {
t.Fatalf("set uncached url empty error %v", b.URLNoCached())
return
}
m := media_library.MediaLibrary{}
m.File.Url = "test2.jpg"
if !strings.Contains(m.File.URLNoCached(), "test2.jpg?") {
t.Fatalf("set uncached url error %v", m.File.URLNoCached())
return
}
m.File.Url = ""
if m.File.URLNoCached() != "" {
t.Fatalf("set uncached url empty error %v", m.File.URLNoCached())
return
}
}
6 changes: 5 additions & 1 deletion media/media_library/media_box.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ func (mediaBox *MediaBox) URL(styles ...string) string {
return mediaBox.Url
}
func (mediaBox *MediaBox) URLNoCached(styles ...string) string {
return mediaBox.URL(styles...) + "?" + fmt.Sprint(time.Now().Nanosecond())
i := mediaBox.URL(styles...)
if i != "" {
return i + "?" + fmt.Sprint(time.Now().Nanosecond())
}
return i
}

func (mediaBox MediaBox) WebpURL(styles ...string) string {
Expand Down
Loading
0