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

Function parseEncoding

http/_negotiation/encoding.ts:40–63  ·  view source on GitHub ↗
(
  str: string,
  i: number,
)

Source from the content-addressed store, hash-verified

38const simpleEncodingRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/;
39
40function parseEncoding(
41 str: string,
42 i: number,
43): EncodingSpecificity | undefined {
44 const match = simpleEncodingRegExp.exec(str);
45 if (!match) {
46 return undefined;
47 }
48
49 const encoding = match[1]!;
50 let q = 1;
51 if (match[2]) {
52 const params = match[2].split(";");
53 for (const param of params) {
54 const p = param.trim().split("=");
55 if (p[0] === "q" && p[1]) {
56 q = parseFloat(p[1]);
57 break;
58 }
59 }
60 }
61
62 return { encoding, o: undefined, q, i, s: undefined };
63}
64
65function specify(
66 encoding: string,

Callers 1

parseAcceptEncodingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected