From 85c5f834a977f65466fa910659f80634e3953da6 Mon Sep 17 00:00:00 2001 From: Colin Ulin Date: Mon, 11 Dec 2023 17:31:34 -0500 Subject: [PATCH] Fixed config bug in parseObject mapping --- spec/ParseAPI.spec.js | 29 +++++++++++++++++++++++++++++ src/Routers/FunctionsRouter.js | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/spec/ParseAPI.spec.js b/spec/ParseAPI.spec.js index 9b1a97af87..984709408d 100644 --- a/spec/ParseAPI.spec.js +++ b/spec/ParseAPI.spec.js @@ -1267,6 +1267,35 @@ describe('miscellaneous', function () { }); }); + it('test cloud function query parameters with array of pointers', done => { + Parse.Cloud.define('echoParams', req => { + return req.params; + }); + const headers = { + 'Content-Type': 'application/json', + 'X-Parse-Application-Id': 'test', + 'X-Parse-Javascript-Key': 'test', + }; + request({ + method: 'POST', + headers: headers, + url: 'http://localhost:8378/1/functions/echoParams', //?option=1&other=2 + qs: { + option: 1, + other: 2, + }, + body: '{"foo":"bar", "other": 1, "arr": [{ "__type": "Pointer" }]}', + }).then(response => { + const res = response.data.result; + expect(res.option).toEqual('1'); + // Make sure query string params override body params + expect(res.other).toEqual('2'); + expect(res.foo).toEqual('bar'); + expect(res.arr.length).toEqual(1); + done(); + }); + }); + it('can handle null params in cloud functions (regression test for #1742)', done => { Parse.Cloud.define('func', request => { expect(request.params.nullParam).toEqual(null); diff --git a/src/Routers/FunctionsRouter.js b/src/Routers/FunctionsRouter.js index bb4b959ebe..eab76eeb1b 100644 --- a/src/Routers/FunctionsRouter.js +++ b/src/Routers/FunctionsRouter.js @@ -12,7 +12,7 @@ import { logger } from '../logger'; function parseObject(obj, config) { if (Array.isArray(obj)) { return obj.map(item => { - return parseObject(item); + return parseObject(item, config); }); } else if (obj && obj.__type == 'Date') { return Object.assign(new Date(obj.iso), obj);