[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

fix(browser): restrict served files from `/__screenshot-error` (#7340)

authored by

Hiroshi Ogawa and committed by
GitHub
(Jan 23, 2025, 7:40 AM +0100) ed9aeba2 45085cf8

+11 -3
+9 -1
packages/browser/src/node/plugin.ts
··· 93 93 } 94 94 95 95 const url = new URL(req.url, 'http://localhost') 96 - const file = url.searchParams.get('file') 96 + const id = url.searchParams.get('id') 97 + if (!id) { 98 + res.statusCode = 404 99 + res.end() 100 + return 101 + } 102 + 103 + const task = parentServer.vitest.state.idMap.get(id) 104 + const file = task?.meta.failScreenshotPath 97 105 if (!file) { 98 106 res.statusCode = 404 99 107 res.end()
+2 -2
packages/ui/client/components/views/ViewReport.vue
··· 116 116 const timestamp = ref(Date.now()) 117 117 const currentTask = ref<Task | undefined>() 118 118 const currentScreenshotUrl = computed(() => { 119 - const file = currentTask.value?.meta.failScreenshotPath 119 + const id = currentTask.value?.id 120 120 // force refresh 121 121 const t = timestamp.value 122 122 // browser plugin using /, change this if base can be modified 123 - return file ? `/__screenshot-error?file=${encodeURIComponent(file)}&t=${t}` : undefined 123 + return id ? `/__screenshot-error?id=${encodeURIComponent(id)}&t=${t}` : undefined 124 124 }) 125 125 126 126 function showScreenshotModal(task: Task) {