(ctx context.Context, src string)
| 287 | } |
| 288 | |
| 289 | func (s *Server) fetchTutorialPoster(ctx context.Context, src string) ([]byte, string, error) { |
| 290 | if !strings.HasPrefix(src, tutorialsPosterOrigin) { |
| 291 | return nil, "", errTutorialPosterOrigin |
| 292 | } |
| 293 | data, ctype, err := s.fetchTutorialBytes(ctx, src, tutorialsPosterMaxSize) |
| 294 | if err != nil { |
| 295 | return nil, "", err |
| 296 | } |
| 297 | switch ctype = strings.ToLower(strings.TrimSpace(strings.Split(ctype, ";")[0])); ctype { |
| 298 | case "image/jpeg", "image/png", "image/webp": |
| 299 | return data, ctype, nil |
| 300 | } |
| 301 | return nil, "", fmt.Errorf("tutorials: poster content type %q", ctype) |
| 302 | } |
no test coverage detected