MCPcopy Index your code
hub / github.com/tinyhttp/tinyhttp / normalize

Function normalize

packages/type-is/src/index.ts:49–63  ·  view source on GitHub ↗
(type: string | unknown)

Source from the content-addressed store, hash-verified

47}
48
49function normalize(type: string | unknown) {
50 // invalid type
51 if (typeof type !== 'string') return false
52
53 switch (type) {
54 case 'urlencoded':
55 return 'application/x-www-form-urlencoded'
56 case 'multipart':
57 return 'multipart/*'
58 }
59 // "+json" -> "*/*+json" expando
60 if (type[0] === '+') return '*/*' + type
61
62 return type.indexOf('/') === -1 ? lookup(type) : type
63}
64
65/**
66 * Compare a `value` content-type with `types`.

Callers 1

typeIsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected