bevry / envfile

Parse and write environment files with Node.js
Other
61 stars 10 forks source link

The parse() does not handle keys with JSON values containing double-quotes #229

Closed kamyar-nemati closed 8 months ago

kamyar-nemati commented 11 months ago

Given the ENV file below:

---env begins here---

APP_NAME=FooBar
APP_COMM_CRED="[{"key":"foo"},{"key":"bar"}]"

---env ends here---

The JSON value of APP_COMM_CRED is deformed and the "key" attributes lose their double-quotes after performing the parse function.

balupton commented 11 months ago

Interesting.

Seems that envfile should use https://github.com/bevry/normalify then.

Happy for you to send a PR.

I do have to merge https://github.com/bevry/envfile/pull/213 sometime as well.

balupton commented 11 months ago

@nampnq in your opinion, would https://github.com/bevry/normalify be suitable for this?

NamPNQ commented 8 months ago

I think we can handle by just check value.startsWith() && value.endsWith() by double quote, or single quote, then we get substring of value

NamPNQ commented 8 months ago

@NamPNQ in your opinion, would https://github.com/bevry/normalify be suitable for this?

IMO, use this will make unexpected behavior, because env value is always is string, not number nor boolean