Bad management of pairs of braces
Heziode opened this issue · comments
Input: TEST_WITH_BRACKET="{ port: $MONGOLAB_PORT}"
Expected: { port: 12345}
Actual: { port: 12345
Possible solution:
Change this line:
Line 8 in de9e5cb
By:
var matches = envValue.match(/(.?\$(?:{(?:[a-zA-Z0-9_]+)?}|(?:[a-zA-Z0-9_]+)?))/g) || []
Coincidentally, the code I wrote in #48 also fixes this issue.
I've added a test for it here: d6f3d97
The issue was that the original regex was conditionally looking for the curly brackets. Which means that ${var
and $var}
would have matched it. My fix expands the regex a bit to explicitly look for strings that have both or neither (as well as $(command)
.
This is fixed in the latest version of dotenv and dotenv-expand.