chore: sync
This commit is contained in:
@@ -35,6 +35,11 @@ func (s *WorkService) WorkExists(workID string) bool {
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func isExternalURL(value string) bool {
|
||||
trimmed := strings.TrimSpace(value)
|
||||
return strings.HasPrefix(trimmed, "http://") || strings.HasPrefix(trimmed, "https://")
|
||||
}
|
||||
|
||||
// ─── Read operations ──────────────────────────────────────────────────────────
|
||||
|
||||
// LoadWork loads and returns a single work config from disk (read-locked).
|
||||
@@ -191,14 +196,22 @@ func (s *WorkService) BuildResponse(w *model.WorkConfig) *model.WorkResponse {
|
||||
if len(w.Screenshots) > 0 {
|
||||
resp.ImageLinks = make([]string, len(w.Screenshots))
|
||||
for i, img := range w.Screenshots {
|
||||
resp.ImageLinks[i] = fmt.Sprintf("/api/image/%s/%s", w.WorkID, img)
|
||||
if isExternalURL(img) {
|
||||
resp.ImageLinks[i] = strings.TrimSpace(img)
|
||||
} else {
|
||||
resp.ImageLinks[i] = fmt.Sprintf("/api/image/%s/%s", w.WorkID, img)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(w.VideoFiles) > 0 {
|
||||
resp.VideoLinks = make([]string, len(w.VideoFiles))
|
||||
for i, vid := range w.VideoFiles {
|
||||
resp.VideoLinks[i] = fmt.Sprintf("/api/video/%s/%s", w.WorkID, vid)
|
||||
if isExternalURL(vid) {
|
||||
resp.VideoLinks[i] = strings.TrimSpace(vid)
|
||||
} else {
|
||||
resp.VideoLinks[i] = fmt.Sprintf("/api/video/%s/%s", w.WorkID, vid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user