File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -115,9 +115,13 @@ class Route extends Model {
115115 const results = await query
116116
117117 return results . map ( ( result ) => {
118- if ( typeof result . waypoints === 'string' ) {
119- result . waypoints = JSON . parse ( result . waypoints )
120- } else if ( result . waypoints === null ) {
118+ if ( typeof result . waypoints === 'string' && result . waypoints ) {
119+ try {
120+ result . waypoints = JSON . parse ( result . waypoints )
121+ } catch {
122+ result . waypoints = [ ]
123+ }
124+ } else if ( ! result . waypoints ) {
121125 result . waypoints = [ ]
122126 }
123127 return result
@@ -162,14 +166,22 @@ class Route extends Model {
162166
163167 if ( ! result ) return null
164168
165- if ( typeof result . waypoints === 'string' ) {
166- result . waypoints = JSON . parse ( result . waypoints )
167- } else if ( result . waypoints === null ) {
169+ if ( typeof result . waypoints === 'string' && result . waypoints ) {
170+ try {
171+ result . waypoints = JSON . parse ( result . waypoints )
172+ } catch {
173+ result . waypoints = [ ]
174+ }
175+ } else if ( ! result . waypoints ) {
168176 result . waypoints = [ ]
169177 }
170- if ( typeof result . tags === 'string' ) {
171- result . tags = JSON . parse ( result . tags )
172- } else if ( result . tags === null ) {
178+ if ( typeof result . tags === 'string' && result . tags ) {
179+ try {
180+ result . tags = JSON . parse ( result . tags )
181+ } catch {
182+ result . tags = [ ]
183+ }
184+ } else if ( ! result . tags ) {
173185 result . tags = [ ]
174186 }
175187 if ( typeof result . image === 'string' ) {
You can’t perform that action at this time.
0 commit comments