@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.
Files changed (2) hide show
  1. package/index.js +1 -4
  2. 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 || !SERVED_ASSETS.has(path.resolve(file)) || !existsSync(file) || !statSync(file).isFile()) {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luosuqwq/dsh-diagram",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Renders explanatory diagrams, web pages and annotated images to PNG, and shows them inline in answers.",
5
5
  "author": "LuoSu <2681153600@qq.com>",
6
6
  "keywords": [