(raw: string)
| 5 | * @see https://opentelemetry.io/docs/specs/otel/protocol/exporter/ |
| 6 | */ |
| 7 | export function parseOtlpHeaders(raw: string): Record<string, string> { |
| 8 | const out: Record<string, string> = {} |
| 9 | if (!raw) return out |
| 10 | for (const part of raw.split(',')) { |
| 11 | const trimmed = part.trim() |
| 12 | if (!trimmed) continue |
| 13 | const eq = trimmed.indexOf('=') |
| 14 | if (eq <= 0) continue |
| 15 | const key = trimmed.slice(0, eq).trim() |
| 16 | if (!key) continue |
| 17 | const rawVal = trimmed.slice(eq + 1).trim() |
| 18 | let val = rawVal |
| 19 | try { |
| 20 | val = decodeURIComponent(rawVal) |
| 21 | } catch { |
| 22 | // value wasn't URL-encoded; keep as-is. |
| 23 | } |
| 24 | out[key] = val |
| 25 | } |
| 26 | return out |
| 27 | } |
no outgoing calls
no test coverage detected