Cleanup JSON parse (#23443)
This commit is contained in:
Родитель
07538b231b
Коммит
aa6c5e1513
|
@ -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
|
||||
*/
|
||||
const headerKeyValue = header.split(new RegExp(/:\s(.*)/s));
|
||||
const headerKey = headerKeyValue[0];
|
||||
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);
|
||||
entries.set(headerKeyValue[0], headerKeyValue[1]);
|
||||
});
|
||||
|
||||
const parsedHeaders = Object.fromEntries(entries) as Record<string, string>;
|
||||
|
@ -257,7 +238,6 @@ const networkRequestViaProxy = <T>(
|
|||
status: httpStatusCode
|
||||
};
|
||||
|
||||
|
||||
if (((httpStatusCode < HttpStatus.SUCCESS_RANGE_START) || (httpStatusCode > HttpStatus.SUCCESS_RANGE_END)) &&
|
||||
// do not destroy the request for the device code flow
|
||||
// @ts-ignore
|
||||
|
|
Загрузка…
Ссылка в новой задаче