Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

environmentalize does not work with object whitelisting #541

Open
jhiode opened this issue Jan 14, 2020 · 0 comments
Open

environmentalize does not work with object whitelisting #541

jhiode opened this issue Jan 14, 2020 · 0 comments

Comments

@jhiode
Copy link
Member

jhiode commented Jan 14, 2020

We noticed in Hops that we can't use environment variables when whitelisting a full object.

Example:

module.exports = {
  foo: {
    bar: '[FOOBAR]',
  },
  browserWhitelist: {
    foo: true, // does not add `FOOBAR` to the list of environment variables and `foo.bar` will be an empty string.
  },
};

It works though if we use the full path for the entry:

module.exports = {
  foo: {
    bar: '[FOOBAR]',
  },
  browserWhitelist: {
    'foo.bar': true, // this works as expected
  },
};

Root cause is that we only check for the full path (line 95):

if (regExp.test(item)) {
return item.replace(regExp, (_, key, fallback) => {
const replaced = env[key] || fallback || '';
if (whitelist[path.join('.')]) {
_env[key] = replaced;
}
return replaceRecursive(replaced);
});
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant