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

Function serializeToken

http/unstable_structured_fields.ts:1338–1356  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

1336}
1337
1338function serializeToken(value: string): string {
1339 if (value.length === 0) {
1340 throw new TypeError("Token cannot be empty");
1341 }
1342
1343 const first = value[0]!;
1344 if (!isAlpha(first) && first !== "*") {
1345 throw new TypeError("Token must start with ALPHA or '*'");
1346 }
1347
1348 for (let i = 1; i < value.length; i++) {
1349 const c = value[i]!;
1350 if (!isTchar(c) && c !== ":" && c !== "/") {
1351 throw new TypeError(`Invalid character in token at position ${i}`);
1352 }
1353 }
1354
1355 return value;
1356}
1357
1358function serializeBinary(value: Uint8Array): string {
1359 return `:${encodeBase64(value)}:`;

Callers 1

serializeBareItemFunction · 0.85

Calls 2

isAlphaFunction · 0.85
isTcharFunction · 0.85

Tested by

no test coverage detected