Skip to content

Commit

Permalink
Merge pull request #204 from Darseen/initOptional-refactor
Browse files Browse the repository at this point in the history
Simplify initOptional function for clarity
  • Loading branch information
minjikarin authored Jan 3, 2024
2 parents b3efb5f + fdea4a7 commit a70fd98
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/amadeus/client/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,9 @@ class Validator {
}

initOptional(key, options, fallback = null) {
let value = options[key];
//Env variables names expected to be in SNAKE_CASE and uppercase
let envKey = `AMADEUS_${key.replace(/[A-Z]/g, c => `_${c.toLowerCase()}`).toUpperCase()}`;
if (value == undefined) { value = options[key]; }
if (value == undefined) { value = process.env[envKey]; }
if (value == undefined) { value = fallback; }
let value = options[key] || process.env[envKey] || fallback;
return value;
}

Expand Down

0 comments on commit a70fd98

Please sign in to comment.