MCPcopy Create free account
hub / github.com/denoland/std / parseAcceptEncoding

Function parseAcceptEncoding

http/_negotiation/encoding.ts:88–115  ·  view source on GitHub ↗
(accept: string)

Source from the content-addressed store, hash-verified

86}
87
88function parseAcceptEncoding(accept: string): EncodingSpecificity[] {
89 const accepts = accept.split(",");
90 const parsedAccepts: EncodingSpecificity[] = [];
91 let hasIdentity = false;
92 let minQuality = 1;
93
94 for (const [i, accept] of accepts.entries()) {
95 const encoding = parseEncoding(accept.trim(), i);
96
97 if (encoding) {
98 parsedAccepts.push(encoding);
99 hasIdentity = hasIdentity || !!specify("identity", encoding);
100 minQuality = Math.min(minQuality, encoding.q || 1);
101 }
102 }
103
104 if (!hasIdentity) {
105 parsedAccepts.push({
106 encoding: "identity",
107 o: undefined,
108 q: minQuality,
109 i: accepts.length - 1,
110 s: undefined,
111 });
112 }
113
114 return parsedAccepts;
115}
116
117function getEncodingPriority(
118 encoding: string,

Callers 1

preferredEncodingsFunction · 0.85

Calls 5

parseEncodingFunction · 0.85
minMethod · 0.80
specifyFunction · 0.70
entriesMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected