MCPcopy
hub / github.com/axios/axios / trimSPorHTAB

Function trimSPorHTAB

lib/helpers/sanitizeHeaderValue.js:5–30  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

3import utils from '../utils.js';
4
5function trimSPorHTAB(str) {
6 let start = 0;
7 let end = str.length;
8
9 while (start < end) {
10 const code = str.charCodeAt(start);
11
12 if (code !== 0x09 && code !== 0x20) {
13 break;
14 }
15
16 start += 1;
17 }
18
19 while (end > start) {
20 const code = str.charCodeAt(end - 1);
21
22 if (code !== 0x09 && code !== 0x20) {
23 break;
24 }
25
26 end -= 1;
27 }
28
29 return start === 0 && end === str.length ? str : str.slice(start, end);
30}
31
32// The control-code ranges are intentional: header sanitization strips C0/DEL bytes.
33// eslint-disable-next-line no-control-regex

Callers 1

sanitizeValueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected