From 0b474751b5fb994d402caf3d0515d95680684b60 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 26 Jan 2020 11:06:03 -0500 Subject: Add simplified isObject test --- ext/bg/js/json-schema.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/json-schema.js b/ext/bg/js/json-schema.js index 5d596a8b..2b7c9f27 100644 --- a/ext/bg/js/json-schema.js +++ b/ext/bg/js/json-schema.js @@ -131,19 +131,19 @@ class JsonSchemaProxyHandler { case 'object': { const properties = schema.properties; - if (properties !== null && typeof properties === 'object' && !Array.isArray(properties)) { + if (JsonSchemaProxyHandler.isObject(properties)) { if (Object.prototype.hasOwnProperty.call(properties, property)) { return properties[property]; } } const additionalProperties = schema.additionalProperties; - return (additionalProperties !== null && typeof additionalProperties === 'object' && !Array.isArray(additionalProperties)) ? additionalProperties : null; + return JsonSchemaProxyHandler.isObject(additionalProperties) ? additionalProperties : null; } case 'array': { const items = schema.items; - return (items !== null && typeof items === 'object' && !Array.isArray(items)) ? items : null; + return JsonSchemaProxyHandler.isObject(items) ? items : null; } default: return null; @@ -399,6 +399,10 @@ class JsonSchemaProxyHandler { return value; } + + static isObject(value) { + return typeof value === 'object' && value !== null && !Array.isArray(value); + } } class JsonSchema { -- cgit v1.2.3