Use Array.isArray rather than typeof ... === 'object' to check Arrayness.

This commit is contained in:
Jesse Rosenberger 2019-02-06 12:24:01 +02:00
parent 8b1b3d795b
commit 3dfbfcc0d8
No known key found for this signature in database
GPG key ID: C0CCCF81AA6C08D8

View file

@ -125,7 +125,7 @@ export class EngineReportingExtension<TContext = any>
for (const [key, value] of o.request.headers) { for (const [key, value] of o.request.headers) {
if ( if (
this.options.privateHeaders && this.options.privateHeaders &&
typeof this.options.privateHeaders === 'object' && Array.isArray(this.options.privateHeaders) &&
// We assume that most users only have a few private headers, or will // We assume that most users only have a few private headers, or will
// just set privateHeaders to true; we can change this linear-time // just set privateHeaders to true; we can change this linear-time
// operation if it causes real performance issues. // operation if it causes real performance issues.
@ -164,7 +164,7 @@ export class EngineReportingExtension<TContext = any>
Object.keys(o.variables).forEach(name => { Object.keys(o.variables).forEach(name => {
if ( if (
this.options.privateVariables && this.options.privateVariables &&
typeof this.options.privateVariables === 'object' && Array.isArray(this.options.privateVariables) &&
// We assume that most users will have only a few private variables, // We assume that most users will have only a few private variables,
// or will just set privateVariables to true; we can change this // or will just set privateVariables to true; we can change this
// linear-time operation if it causes real performance issues. // linear-time operation if it causes real performance issues.