mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-04-15 03:02:51 -05:00
fix(core): fix bug about isObject function (#3647)
This commit is contained in:
parent
1641dc3325
commit
378e907d53
3 changed files with 14 additions and 7 deletions
5
.changeset/poor-suns-film.md
Normal file
5
.changeset/poor-suns-film.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@verdaccio/core': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(core): fix `isObject` function.`isObject(true)` should return false.
|
|
@ -95,14 +95,15 @@ export function normalizeMetadata(manifest: Manifest, name: string): Manifest {
|
||||||
* @return {Boolean}
|
* @return {Boolean}
|
||||||
*/
|
*/
|
||||||
export function isObject(obj: any): boolean {
|
export function isObject(obj: any): boolean {
|
||||||
if (obj === null || typeof obj === 'undefined' || typeof obj === 'string') {
|
// if (obj === null || typeof obj === 'undefined' || typeof obj === 'string') {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return (
|
// return (
|
||||||
(typeof obj === 'object' || typeof obj.prototype === 'undefined') &&
|
// (typeof obj === 'object' || typeof obj.prototype === 'undefined') &&
|
||||||
Array.isArray(obj) === false
|
// Array.isArray(obj) === false
|
||||||
);
|
// );
|
||||||
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function validatePassword(
|
export function validatePassword(
|
||||||
|
|
|
@ -31,6 +31,7 @@ describe('isObject', () => {
|
||||||
expect(isObject(['foo'])).toBeFalsy();
|
expect(isObject(['foo'])).toBeFalsy();
|
||||||
expect(isObject(null)).toBeFalsy();
|
expect(isObject(null)).toBeFalsy();
|
||||||
expect(isObject(undefined)).toBeFalsy();
|
expect(isObject(undefined)).toBeFalsy();
|
||||||
|
expect(isObject(true)).toBeFalsy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue