@dyno181cm.nexsoft/zentao_mcp 1.2.10 → 1.2.11

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/build/tools.js +16 -4
  2. package/package.json +1 -1
package/build/tools.js CHANGED
@@ -42,10 +42,21 @@ function formatUser(user) {
42
42
  }
43
43
  return String(user);
44
44
  }
45
+ /** Convert a local absolute path to a valid file:// URL. */
46
+ function toFileUrl(filePath) {
47
+ const normalized = filePath.replace(/\\/g, '/');
48
+ if (/^[a-zA-Z]:\//.test(normalized)) {
49
+ return `file:///${normalized}`;
50
+ }
51
+ if (normalized.startsWith('/')) {
52
+ return `file://${normalized}`;
53
+ }
54
+ return `file:///${normalized}`;
55
+ }
45
56
  /**
46
57
  * Find all <img src="..."> URLs in an HTML string, download each image
47
58
  * to the local tmp directory using the authenticated ZenTao client,
48
- * and replace the remote src with the local file path.
59
+ * and replace the remote src with the local file:// URL.
49
60
  * Images already cached on disk are not re-downloaded.
50
61
  */
51
62
  async function localizeImages(html) {
@@ -65,7 +76,7 @@ async function localizeImages(html) {
65
76
  if (!fs.existsSync(localPath)) {
66
77
  await client.downloadImageToLocal(remoteUrl, localPath);
67
78
  }
68
- result = result.split(remoteUrl).join(localPath);
79
+ result = result.split(remoteUrl).join(toFileUrl(localPath));
69
80
  }
70
81
  catch {
71
82
  // If download fails, keep the original remote URL
@@ -121,9 +132,10 @@ async function renderAttachments(files) {
121
132
  const lines = enriched.map((f) => {
122
133
  if (!f.localPath)
123
134
  return `- 📎 ${f.title} — *(download failed, Size: ${formatSize(f.size)})*`;
135
+ const fileUrl = toFileUrl(f.localPath);
124
136
  if (IMAGE_EXTS.has(f.ext))
125
- return `- 📎 ![${f.title}](${f.localPath}) *(Size: ${formatSize(f.size)})*`;
126
- return `- 📎 [${f.title}](${f.localPath}) *(Size: ${formatSize(f.size)})*`;
137
+ return `- 📎 ![${f.title}](${fileUrl}) *(Size: ${formatSize(f.size)})*`;
138
+ return `- 📎 [${f.title}](${fileUrl}) *(Size: ${formatSize(f.size)})*`;
127
139
  });
128
140
  return `\n## Files 📎${headerHint}\n${lines.join('\n')}\n`;
129
141
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dyno181cm.nexsoft/zentao_mcp",
3
- "version": "1.2.10",
3
+ "version": "1.2.11",
4
4
  "description": "Zentao MCP Server",
5
5
  "repository": {
6
6
  "type": "git",