Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit aa1b0ac

Browse files
committed
bugfix: guard against arr not defined
bugfix: delete working with workspace
1 parent cf8b0cb commit aa1b0ac

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/components/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,10 @@ import AnalysisCard from './Analysis'
328328
import Vue from 'vue'
329329
import { sanitizeAreaName } from '../util/fn'
330330
331-
const fA = (arr) => arr.concat(
331+
const fA = (arr) => (arr && arr.concat(
332332
...arr.map(item =>item.children && item.children.length
333333
? fA(item.children)
334-
: [])
334+
: [])) || []
335335
)
336336
337337
import { allowedParcellationName, allowedTemplateSpaces, hardcode } from './constants'

vueSsr/analysisRoute.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,22 @@ const checkPermission = (req, res, next) => {
5656
return res.status(404).send('analysis does not exist on the workspace')
5757
}
5858

59-
const putAnalysisMiddleWare = (req, res, next) => {
59+
const mutateWorkspaceMiddleWare = (req, res, next) => {
6060
const arr = getWorkSpace(req)
6161
const { analysisId } = req.params
6262
if (analysisId) {
63-
arr.push(analysisId)
64-
return next()
63+
if (req.method === 'PUT') {
64+
arr.push(analysisId)
65+
return next()
66+
}
67+
else if (req.method === 'DELETE') {
68+
const idx = arr.indexOf(analysisId)
69+
if (idx < 0) return res.status(404).send()
70+
arr.splice(idx, 1)
71+
return next()
72+
} else {
73+
return res.status(405).send()
74+
}
6575
} else {
6676
return res.status(400).send('analysisId is required')
6777
}
@@ -137,7 +147,7 @@ router.post('/analysisCB/:randomToken', (req, res) => {
137147
})
138148
})
139149

140-
router.put('/:analysisId', putAnalysisMiddleWare, (req, res) => {
150+
router.put('/:analysisId', mutateWorkspaceMiddleWare, (req, res) => {
141151
const { analysisId } = req.params
142152
const { body } = req
143153

@@ -183,7 +193,7 @@ router.put('/:analysisId', putAnalysisMiddleWare, (req, res) => {
183193
})
184194
})
185195

186-
router.delete('/:analysisId', checkPermission, (req, res) => {
196+
router.delete('/:analysisId', checkPermission, mutateWorkspaceMiddleWare, (req, res) => {
187197
const { analysisId } = req.params
188198
const flag = map.delete(analysisId)
189199
const flag2 = result.delete(analysisId)

0 commit comments

Comments
 (0)