mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-21 16:00:59 -05:00
Added proper support for MultiMap
to getHeader
This commit is contained in:
parent
cf2e81d32f
commit
8c5467ce2d
1 changed files with 7 additions and 2 deletions
|
@ -38,13 +38,18 @@ export function getHeader(headers: Headers, header: string): string | undefined
|
|||
return undefined;
|
||||
}
|
||||
|
||||
if (isMultiMap<string, string>(headers)) {
|
||||
const entries = headers.get(header);
|
||||
return typeof entries === "string" ? entries : entries ? asArrayLike(entries).join(HEADER_SEPARATOR) : undefined;
|
||||
}
|
||||
|
||||
if (isMap<string, string>(headers)) {
|
||||
return headers.get(header);
|
||||
}
|
||||
|
||||
if (isIterable<string>(headers)) {
|
||||
if (isIterable<Iterable<string>>(headers)) {
|
||||
const arrayLikeHeaders = asArrayLike(headers);
|
||||
return arrayLikeHeaders.find(x => asArrayLike(x).at(0) === header);
|
||||
return arrayLikeHeaders.find(x => asArrayLike(x).at(0) === header)?.[1];
|
||||
}
|
||||
|
||||
return headers[header];
|
||||
|
|
Loading…
Reference in a new issue