diff --git a/lib/util/template/index.spec.ts b/lib/util/template/index.spec.ts index 286738231b05f8..5318304e33e98f 100644 --- a/lib/util/template/index.spec.ts +++ b/lib/util/template/index.spec.ts @@ -116,22 +116,25 @@ describe('util/template/index', () => { describe('proxyCompileInput', () => { const allowedField = 'body'; + const allowedArrayField = 'prBodyNotes'; const forbiddenField = 'foobar'; type TestCompileInput = Record< - typeof allowedField | typeof forbiddenField, + typeof allowedField | typeof allowedArrayField | typeof forbiddenField, unknown >; const compileInput: TestCompileInput = { [allowedField]: 'allowed', + [allowedArrayField]: ['allowed'], [forbiddenField]: 'forbidden', }; - it('accessing allowed files', () => { + it('accessing allowed fields', () => { const p = template.proxyCompileInput(compileInput); expect(p[allowedField]).toBe('allowed'); + expect(p[allowedArrayField]).toStrictEqual(['allowed']); expect(p[forbiddenField]).toBeUndefined(); }); @@ -153,6 +156,7 @@ describe('util/template/index', () => { const arr = proxy[allowedField] as TestCompileInput[]; const obj = arr[0]; expect(obj[allowedField]).toBe('allowed'); + expect(obj[allowedArrayField]).toStrictEqual(['allowed']); expect(obj[forbiddenField]).toBeUndefined(); }); }); diff --git a/lib/util/template/index.ts b/lib/util/template/index.ts index c4fcd4fcc564b6..f3e4a8809c7e6f 100644 --- a/lib/util/template/index.ts +++ b/lib/util/template/index.ts @@ -185,9 +185,11 @@ const compileInputProxyHandler: ProxyHandler = { const value = target[prop]; if (is.array(value)) { - return value - .filter(is.plainObject) - .map((element) => proxyCompileInput(element as CompileInput)); + return value.map((element) => + is.primitive(element) + ? element + : proxyCompileInput(element as CompileInput) + ); } if (is.plainObject(value)) {