File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed
application/frontend/src/utils Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -22,23 +22,22 @@ export const emulateData = (amount) => {
2222} ;
2323
2424export const tryToParseLogString = ( str ) => {
25- const beginningOfJson = str . indexOf ( "{" ) ;
26- const endingOfJson = str . lastIndexOf ( "}" ) ;
25+ const beginningOfJson = str . search ( / [ { [ ] / ) ;
26+ const endingOfJson = str . search ( / [ \] } ] (? ! [ \s \S ] * [ \] } ] ) / ) ;
2727
2828 let html = "" ;
2929 let startText = "" ;
3030 let endText = "" ;
3131
32- if ( beginningOfJson !== - 1 && endingOfJson !== - 1 ) {
33- if ( endingOfJson > beginningOfJson ) {
34- const jsonPart = str . slice ( beginningOfJson , endingOfJson ) ;
35- startText = str . slice ( 0 , beginningOfJson ) ;
36- endText = str . slice ( endingOfJson + 1 , - 1 ) ;
37- try {
38- let normilizedStr = JSON . parse ( jsonPart + "}" ) ;
39- html = json2html ( normilizedStr , 2 ) ;
40- } catch ( e ) { }
41- }
32+ if ( beginningOfJson !== - 1 && endingOfJson !== - 1 && endingOfJson > beginningOfJson ) {
33+ const jsonPart = str . slice ( beginningOfJson , endingOfJson + 1 ) ;
34+ startText = str . slice ( 0 , beginningOfJson ) ;
35+ endText = str . slice ( endingOfJson + 1 ) ;
36+
37+ try {
38+ const parsed = JSON . parse ( jsonPart ) ;
39+ html = json2html ( parsed , 2 ) ;
40+ } catch ( e ) { }
4241 }
4342
4443 if ( html ) {
You can’t perform that action at this time.
0 commit comments