motdotla / dotenv-expand

Variable expansion for dotenv. Expand variables already on your machine for use in your .env file.

Home Page:https://dotenvx.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow to use env variables with '.' in it's name (i.e. REDIS.PUBSUB.PORT)

flamewow opened this issue · comments

currently, if I want to use a variable whose name contains "." (e.g. REDIS.PUBSUB.PORT) the lib is not working.

Should be as simple as changing regex to allow "."

  const matches = envValue.match(/(.?\${*[\w\.]*(?::-[\w/]*)?}*)/g) || []

  return matches.reduce(function (newEnv, match, index) {
    const parts = /(.?)\${*([\w\.]*(?::-[\w/]*)?)?}*/g.exec(match)
    if (!parts || parts.length === 0) {
      return newEnv
    }

the PR #93

commented

our position on variable names is:

For the sake of portability (and sanity), environment variable names must consist solely of letters, digits, and the underscore ( _ ) and must not begin with a digit. In regex-speak, the names must match the following pattern:

https://dotenvx.com/docs/env-file#variable-names

that said, i would like to hear from people who simply do not have control over these env variable names. if so, what service is setting them like that for you? i've never seen that before in the many hosting, db, and other 3rd party services I've used.