cvitool 1.0.779 → 1.0.781
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/CHANGELOG.md +9 -1
- package/build/src/cutil.js +2 -2
- package/package.json +1 -1
- package/src/cutil.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -36,4 +36,12 @@
|
|
|
36
36
|
|
|
37
37
|
## [1.0.779] - 2025-10-29
|
|
38
38
|
### Fixed
|
|
39
|
-
- 修复checkURLResource函数请求发生ENOTFOUND时抛错问题
|
|
39
|
+
- 修复checkURLResource函数请求发生ENOTFOUND时抛错问题
|
|
40
|
+
|
|
41
|
+
## [1.0.780] - 2025-11-11
|
|
42
|
+
### Fixed
|
|
43
|
+
- 修复getFileType函数未获取到文件类型时报错问题
|
|
44
|
+
|
|
45
|
+
## [1.0.781] - 2025-11-19
|
|
46
|
+
### Fixed
|
|
47
|
+
- 修复validate函数校验number类型时值为NaN或正负无穷大时误判问题
|
package/build/src/cutil.js
CHANGED
|
@@ -440,7 +440,7 @@ function validate(value, rule, finalFunc) {
|
|
|
440
440
|
return result;
|
|
441
441
|
}
|
|
442
442
|
if (fieldValue !== null) {
|
|
443
|
-
if (getValueType(fieldValue) !== type) {
|
|
443
|
+
if (getValueType(fieldValue) !== type || (type === 'number' && (isNaN(fieldValue) || [+Infinity, -Infinity].includes(fieldValue)))) {
|
|
444
444
|
result.message = `field type must be: ${type}`;
|
|
445
445
|
result.pass = false;
|
|
446
446
|
return result;
|
|
@@ -648,7 +648,7 @@ function getFileType(input_1) {
|
|
|
648
648
|
if (getValueType(input) === 'buffer') {
|
|
649
649
|
stream = stream_1.Readable.from([input]);
|
|
650
650
|
}
|
|
651
|
-
const { ext = '', mime = '' } = yield (0, file_type_1.fromStream)(stream);
|
|
651
|
+
const { ext = '', mime = '' } = (yield (0, file_type_1.fromStream)(stream)) || {};
|
|
652
652
|
if (!ext || !mime) {
|
|
653
653
|
return {
|
|
654
654
|
type: 'unknow',
|
package/package.json
CHANGED
package/src/cutil.ts
CHANGED
|
@@ -481,7 +481,7 @@ function validate(value: { [key: string]: any }, rule: { [key: string]: validate
|
|
|
481
481
|
return result;
|
|
482
482
|
}
|
|
483
483
|
if (fieldValue !== null) {
|
|
484
|
-
if (getValueType(fieldValue) !== type) {
|
|
484
|
+
if (getValueType(fieldValue) !== type || (type === 'number' && (isNaN(fieldValue) || [+Infinity, -Infinity].includes(fieldValue)))) {
|
|
485
485
|
result.message = `field type must be: ${type}`;
|
|
486
486
|
result.pass = false;
|
|
487
487
|
return result;
|
|
@@ -691,7 +691,7 @@ async function getFileType(input: string | Buffer | Readable, reqUrlTimeout = 10
|
|
|
691
691
|
if (getValueType(input) === 'buffer') {
|
|
692
692
|
stream = Readable.from([input as Buffer]);
|
|
693
693
|
}
|
|
694
|
-
const { ext = '', mime = '' } = await fromStream(stream);
|
|
694
|
+
const { ext = '', mime = '' } = (await fromStream(stream)) || {};
|
|
695
695
|
if (!ext || !mime) {
|
|
696
696
|
return {
|
|
697
697
|
type: 'unknow',
|