@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.
- package/client/core.ts +3 -3
- 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(/[
|
|
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);
|