MCPcopy Create free account
hub / github.com/cloudflare/computer / contentTypeForPath

Function contentTypeForPath

packages/computer/src/assets/mime.ts:54–60  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

52// match is case-insensitive. Returns DEFAULT_CONTENT_TYPE when the
53// path has no extension or the extension isn't in the table.
54export function contentTypeForPath(path: string): string {
55 const base = path.slice(path.lastIndexOf("/") + 1);
56 const dot = base.lastIndexOf(".");
57 if (dot <= 0) return DEFAULT_CONTENT_TYPE;
58 const ext = base.slice(dot + 1).toLowerCase();
59 return TYPES[ext] ?? DEFAULT_CONTENT_TYPE;
60}

Callers 2

shareFunction · 0.85
mime.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected