@cnbcool/cnb-api-generate 2.9.1 → 2.9.3

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/client/core.ts +3 -3
  2. package/package.json +1 -1
package/client/core.ts CHANGED
@@ -80,7 +80,7 @@ async function formatResponse(data: any, response: any) {
80
80
  'application/json',
81
81
  'text/json',
82
82
  ].some((t) => contentType.includes(t));
83
- const isText = contentType.startsWith('text/') || contentType.includes('xml');
83
+ const isText = contentType.startsWith('text/') || contentType.includes('/xml') || contentType.includes('+xml');
84
84
  try {
85
85
  if (isJson) {
86
86
  responseData.data = await response.json();
@@ -100,8 +100,8 @@ async function formatResponse(data: any, response: any) {
100
100
  let decoded = decodeURIComponent(lastSegment);
101
101
  // 拒绝空字节(不同 OS/Node.js 版本行为不一致)
102
102
  if (decoded.includes('\0')) throw new Error('Invalid filename: contains null byte');
103
- // 只保留安全字符:字母、数字、下划线、连字符、点号
104
- fileName = decoded.replace(/[^a-zA-Z0-9._-]/g, '_');
103
+ // 最小化过滤:只去除控制字符和跨平台不允许的文件名字符
104
+ fileName = decoded.replace(/[<>:"/\\|?*\x00-\x1f]/g, '_');
105
105
  }
106
106
  } catch (err) {
107
107
  console.warn('[cnb-api] Failed to parse filename from URL:', err instanceof Error ? err.message : err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cnbcool/cnb-api-generate",
3
- "version": "2.9.1",
3
+ "version": "2.9.3",
4
4
  "main": "./built/index.js",
5
5
  "module": "./src/index.ts",
6
6
  "types": "./src/index.ts",