mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Cleanup JSON parse (#23443)
This commit is contained in:
@@ -228,26 +228,7 @@ const networkRequestViaProxy = <T>(
|
|||||||
* there may be more than one ':' if the value of the header is supposed to be a JSON object
|
* there may be more than one ':' if the value of the header is supposed to be a JSON object
|
||||||
*/
|
*/
|
||||||
const headerKeyValue = header.split(new RegExp(/:\s(.*)/s));
|
const headerKeyValue = header.split(new RegExp(/:\s(.*)/s));
|
||||||
const headerKey = headerKeyValue[0];
|
entries.set(headerKeyValue[0], headerKeyValue[1]);
|
||||||
let headerValue = headerKeyValue[1];
|
|
||||||
|
|
||||||
// check if the value of the header is supposed to be a JSON object
|
|
||||||
try {
|
|
||||||
// TODO: Investigate this - https://github.com/microsoft/azuredatastudio/issues/22835
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
||||||
const object = JSON.parse(headerValue);
|
|
||||||
|
|
||||||
// if it is, then convert it from a string to a JSON object
|
|
||||||
if (object && (typeof object === 'object')) {
|
|
||||||
// TODO: Investigate this - https://github.com/microsoft/azuredatastudio/issues/22835
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
||||||
headerValue = object;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
// otherwise, leave it as a string
|
|
||||||
}
|
|
||||||
|
|
||||||
entries.set(headerKey, headerValue);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const parsedHeaders = Object.fromEntries(entries) as Record<string, string>;
|
const parsedHeaders = Object.fromEntries(entries) as Record<string, string>;
|
||||||
@@ -257,7 +238,6 @@ const networkRequestViaProxy = <T>(
|
|||||||
status: httpStatusCode
|
status: httpStatusCode
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if (((httpStatusCode < HttpStatus.SUCCESS_RANGE_START) || (httpStatusCode > HttpStatus.SUCCESS_RANGE_END)) &&
|
if (((httpStatusCode < HttpStatus.SUCCESS_RANGE_START) || (httpStatusCode > HttpStatus.SUCCESS_RANGE_END)) &&
|
||||||
// do not destroy the request for the device code flow
|
// do not destroy the request for the device code flow
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|||||||
Reference in New Issue
Block a user