2
0
mirror of synced 2025-02-23 19:48:28 +00:00

Do not mutate connection in fetchJson.

This commit is contained in:
Richard Moore 2020-08-04 20:49:40 -04:00
parent d38ebaeb23
commit e1bbb064a1
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651

View File

@ -313,7 +313,7 @@ export function fetchJson(connection: string | ConnectionInfo, json?: string, pr
body = toUtf8Bytes(json);
// Create a connection with the content-type set for JSON
const updated: ConnectionInfo = (typeof(connection) === "string") ? ({ url: connection }): connection;
const updated: ConnectionInfo = (typeof(connection) === "string") ? ({ url: connection }): shallowCopy(connection);
if (updated.headers) {
const hasContentType = (Object.keys(updated.headers).filter((k) => (k.toLowerCase() === "content-type")).length) !== 0;
if (!hasContentType) {