This is an automated email from the ASF dual-hosted git repository.
dubeejw pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/incubator-openwhisk-package-cloudant.git
The following commit(s) were added to refs/heads/master by this push:
new a2721f1 updates to query_params validation (#164)
a2721f1 is described below
commit a2721f10e67340ccbd78a9a15ec7b62b1b38cab4
Author: Jason Peterson <[email protected]>
AuthorDate: Mon Mar 19 21:52:18 2018 -0400
updates to query_params validation (#164)
---
actions/changesWebAction.js | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/actions/changesWebAction.js b/actions/changesWebAction.js
index 73b24ac..f69e286 100644
--- a/actions/changesWebAction.js
+++ b/actions/changesWebAction.js
@@ -38,19 +38,17 @@ function main(params) {
var query_params;
if (params.filter) {
- if (typeof params.query_params === 'object') {
- query_params = params.query_params;
- }
- else if (typeof params.query_params === 'string') {
+ query_params = params.query_params;
+ if (typeof queryParams === 'string') {
try {
query_params = JSON.parse(params.query_params);
}
catch (e) {
return sendError(400, 'The query_params parameter cannot
be parsed. Ensure it is valid JSON.');
}
- if (typeof query_params !== 'object') {
- return sendError(400, 'The query_params parameter is not
valid JSON');
- }
+ }
+ if (typeof query_params !== 'object') {
+ return sendError(400, 'The query_params parameter is not valid
JSON');
}
}
else if (params.query_params) {
@@ -162,20 +160,19 @@ function main(params) {
}
if (params.query_params) {
if (updatedParams.filter) {
- if (typeof params.query_params === 'object') {
- updatedParams.query_params =
params.query_params;
- }
- else if (typeof params.query_params === 'string') {
+ var query_params = params.query_params;
+ if (typeof query_params === 'string') {
try {
- updatedParams.query_params =
JSON.parse(params.query_params);
+ query_params =
JSON.parse(params.query_params);
}
catch (e) {
reject(sendError(400, 'The query_params
parameter cannot be parsed. Ensure it is valid JSON.'));
}
- if (typeof updatedParams.query_params !==
'object') {
- reject(sendError(400, 'The query_params
parameter is not valid JSON'));
- }
}
+ if (typeof query_params !== 'object') {
+ reject(sendError(400, 'The query_params
parameter is not valid JSON'));
+ }
+ updatedParams.query_params = query_params;
} else {
reject(sendError(400, 'The query_params parameter
is only allowed if the filter parameter is defined'));
}
--
To stop receiving notification emails like this one, please contact
[email protected].