Skip to content

Commit

Permalink
fixes regex mistake
Browse files Browse the repository at this point in the history
Signed-off-by: Matus Majchrak <[email protected]>
  • Loading branch information
matus-m committed Aug 9, 2019
1 parent 510f77e commit 4686931
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ import { KeyValuePair, Link } from '../../../../types/trace';

import './KeyValuesTable.css';

const jsonObjectOrArrayStartRegex = '/^({|[)/';
const jsonObjectOrArrayStartRegex = /^(\[|\{)/;

function parseIfComplexJson(value: any) {
// if the value is a string representing actual json object or array, then use json-markup
if (typeof value === 'string' && jsonObjectOrArrayStartRegex.match(value)) {
if (typeof value === 'string' && value.match(jsonObjectOrArrayStartRegex)) {
// otherwise just return as is
try {
console.log('parsing JSON');
return JSON.parse(value);
// eslint-disable-next-line no-empty
} catch (_) {}
Expand Down

0 comments on commit 4686931

Please sign in to comment.