You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/03/20 01:52:20 UTC

[GitHub] dubee closed pull request #164: updates to query_params validation

dubee closed pull request #164: updates to query_params validation
URL: https://github.com/apache/incubator-openwhisk-package-cloudant/pull/164
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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'));
                         }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services