mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-24 21:15:51 +01:00
fix(core): fix bug about isObject function (#3647)
This commit is contained in:
parent
1641dc3325
commit
378e907d53
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}
|
||||
*/
|
||||
export function isObject(obj: any): boolean {
|
||||
if (obj === null || typeof obj === 'undefined' || typeof obj === 'string') {
|
||||
return false;
|
||||
}
|
||||
// if (obj === null || typeof obj === 'undefined' || typeof obj === 'string') {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return (
|
||||
(typeof obj === 'object' || typeof obj.prototype === 'undefined') &&
|
||||
Array.isArray(obj) === false
|
||||
);
|
||||
// return (
|
||||
// (typeof obj === 'object' || typeof obj.prototype === 'undefined') &&
|
||||
// Array.isArray(obj) === false
|
||||
// );
|
||||
return Object.prototype.toString.call(obj) === '[object Object]';
|
||||
}
|
||||
|
||||
export function validatePassword(
|
||||
|
@ -31,6 +31,7 @@ describe('isObject', () => {
|
||||
expect(isObject(['foo'])).toBeFalsy();
|
||||
expect(isObject(null)).toBeFalsy();
|
||||
expect(isObject(undefined)).toBeFalsy();
|
||||
expect(isObject(true)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user