MCPcopy Create free account
hub / github.com/cli/cli / supportedContentType

Function supportedContentType

internal/attachments/userasset.go:172–185  ·  view source on GitHub ↗

supportedContentType maps a file extension to the content type the endpoint expects. The extension is all gh checks, since the endpoint accepts mislabeled bytes anyway.

(path string)

Source from the content-addressed store, hash-verified

170// expects. The extension is all gh checks, since the endpoint accepts
171// mislabeled bytes anyway.
172func supportedContentType(path string) (string, error) {
173 ext := strings.ToLower(filepath.Ext(path))
174 for _, t := range contentTypes {
175 if t.ext == ext {
176 return t.contentType, nil
177 }
178 }
179
180 supported := make([]string, len(contentTypes))
181 for i, t := range contentTypes {
182 supported[i] = strings.TrimPrefix(t.ext, ".")
183 }
184 return "", fmt.Errorf("%s is not a supported file type (supported: %s)", path, strings.Join(supported, ", "))
185}
186
187// altEscaper neutralizes the characters that let alt text break out of the
188// image syntax. Without it, alt text containing `](url)` closes the image early

Callers 1

newAssetFunction · 0.85

Calls 2

JoinMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected