From cbf6a96ce4c7f45a7456ce60fc294510a55f25ff Mon Sep 17 00:00:00 2001 From: Timmy Luong Date: Tue, 16 Jun 2020 20:12:40 -0700 Subject: [PATCH] fix(ui): remove newlines in fromFlux parser only for time strings --- ui/src/shared/utils/fromFlux.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ui/src/shared/utils/fromFlux.ts b/ui/src/shared/utils/fromFlux.ts index 743cae9090..c28d08bac2 100644 --- a/ui/src/shared/utils/fromFlux.ts +++ b/ui/src/shared/utils/fromFlux.ts @@ -29,16 +29,13 @@ const TO_COLUMN_TYPE: TypeTranslationMap = { type ParsedReturnTypes = string | undefined | null | number | boolean function parseValue( - value: string, + value: string | undefined, columnType: InternalTypes ): ParsedReturnTypes { - if (!value) { - return value + if (value === undefined) { + return undefined } - // remove newlines from the last column - value = value.replace(/(\r\n|\n|\r)/gm, '') - if (value === 'null') { return null } @@ -60,7 +57,7 @@ function parseValue( } if (columnType === InternalTypes.time) { - return Date.parse(value) + return Date.parse(value.replace(/(\r\n|\n|\r)/gm, '')) // remove newlines from time strings } if (columnType === InternalTypes.number && value === '') {