Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions server/src/models/Route.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,13 @@ class Route extends Model {
const results = await query

return results.map((result) => {
if (typeof result.waypoints === 'string') {
result.waypoints = JSON.parse(result.waypoints)
} else if (result.waypoints === null) {
if (typeof result.waypoints === 'string' && result.waypoints) {
try {
result.waypoints = JSON.parse(result.waypoints)
} catch {
result.waypoints = []
}
} else if (!result.waypoints) {
result.waypoints = []
}
return result
Expand Down Expand Up @@ -162,14 +166,22 @@ class Route extends Model {

if (!result) return null

if (typeof result.waypoints === 'string') {
result.waypoints = JSON.parse(result.waypoints)
} else if (result.waypoints === null) {
if (typeof result.waypoints === 'string' && result.waypoints) {
try {
result.waypoints = JSON.parse(result.waypoints)
} catch {
result.waypoints = []
}
} else if (!result.waypoints) {
result.waypoints = []
}
if (typeof result.tags === 'string') {
result.tags = JSON.parse(result.tags)
} else if (result.tags === null) {
if (typeof result.tags === 'string' && result.tags) {
try {
result.tags = JSON.parse(result.tags)
} catch {
result.tags = []
}
} else if (!result.tags) {
result.tags = []
}
if (typeof result.image === 'string') {
Expand Down
Loading