Skip to content

Commit cf36a15

Browse files
authored
lib: remove version variable from getVersion (cloudevents#163)
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 <[email protected]>
1 parent e2233f8 commit cf36a15

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/bindings/http/http_receiver.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,18 @@ function getMode(headers) {
6868
}
6969

7070
function getVersion(mode, headers, body) {
71-
let version = SPEC_V1; // default to 1.0
72-
7371
if (mode === "binary") {
7472
// Check the headers for the version
7573
const versionHeader = headers[DEFAULT_SPEC_VERSION_HEADER];
76-
if (versionHeader) { version = versionHeader; }
74+
if (versionHeader) {
75+
return versionHeader;
76+
}
7777
} else {
7878
// structured mode - the version is in the body
79-
version = body instanceof String
79+
return body instanceof String
8080
? JSON.parse(body).specversion : body.specversion;
8181
}
82-
return version;
82+
return SPEC_V1;
8383
}
8484

8585
module.exports = HTTPReceiver;

0 commit comments

Comments
 (0)