From 70c5ee9b7b8a82f5d37d436e2ee864630f70e29e Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 15 May 2020 06:01:30 +0200 Subject: [PATCH] lib: remove version variable from getVersion This commit removes the version variable from getVersion and updates the code to use return statements to be consistent with other functions in this file, like getMode and accept. Signed-off-by: Daniel Bevenius --- lib/bindings/http/http_receiver.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/bindings/http/http_receiver.js b/lib/bindings/http/http_receiver.js index 2ffd79f8..803401de 100644 --- a/lib/bindings/http/http_receiver.js +++ b/lib/bindings/http/http_receiver.js @@ -68,18 +68,18 @@ function getMode(headers) { } function getVersion(mode, headers, body) { - let version = SPEC_V1; // default to 1.0 - if (mode === "binary") { // Check the headers for the version const versionHeader = headers[DEFAULT_SPEC_VERSION_HEADER]; - if (versionHeader) { version = versionHeader; } + if (versionHeader) { + return versionHeader; + } } else { // structured mode - the version is in the body - version = body instanceof String + return body instanceof String ? JSON.parse(body).specversion : body.specversion; } - return version; + return SPEC_V1; } module.exports = HTTPReceiver;