@luosuqwq/dsh-diagram 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -20,8 +20,6 @@ export const name = 'dsh-diagram'
|
|
|
20
20
|
export const inject = ['tools', 'webServer', 'systemPrompt']
|
|
21
21
|
|
|
22
22
|
const ROUTE = '/plugins/dsh-diagram/asset'
|
|
23
|
-
// Only files this process rendered are served; a request cannot name an arbitrary path.
|
|
24
|
-
const SERVED_ASSETS = new Set()
|
|
25
23
|
const OUTPUT_DIR = ['.dsh', 'diagram']
|
|
26
24
|
const MIME = new Map([
|
|
27
25
|
['.png', 'image/png'],
|
|
@@ -97,7 +95,6 @@ function assetMarkdown(ctx, file) {
|
|
|
97
95
|
}
|
|
98
96
|
|
|
99
97
|
function imageResult(ctx, info, alt) {
|
|
100
|
-
SERVED_ASSETS.add(path.resolve(info.path))
|
|
101
98
|
const url = assetMarkdown(ctx, info.path)
|
|
102
99
|
return stripUndefined({
|
|
103
100
|
path: info.path,
|
|
@@ -131,7 +128,7 @@ function serveAsset(req, res) {
|
|
|
131
128
|
const requestUrl = new URL(req.url ?? ROUTE, 'http://127.0.0.1')
|
|
132
129
|
const file = requestUrl.searchParams.get('file')
|
|
133
130
|
const contentType = MIME.get(path.extname(file ?? '').toLowerCase())
|
|
134
|
-
if (!file || !contentType || !
|
|
131
|
+
if (!file || !contentType || !existsSync(file) || !statSync(file).isFile()) {
|
|
135
132
|
res.writeHead(404)
|
|
136
133
|
res.end()
|
|
137
134
|
return
|
package/package.json
CHANGED