thesimj / envyaml

Simple YAML configuration file parser
MIT License
78 stars 21 forks source link

Failing to read default value if using space before pipe character #48

Open andret13pinto opened 1 year ago

andret13pinto commented 1 year ago

Describe the bug

When using a default value for an enviroment variable, if a space is used before the pipe character, the enviroment variable is not read.

To Reproduce

Example buggy env.yaml:

database:
  address: $DATABASE_HOST | localhost
  port: $DATABASE_PORT | 5127

redis:
  connection_string: $REDIS_HOST | redis

By removing the extra space we manage to read the default variables:

working env.yaml:

database:
  address: $DATABASE_HOST| localhost
  port: $DATABASE_PORT| 5127

redis:
  connection_string: $REDIS_HOST| redis

Expected behavior

I think this leads faulty behaviour since it's not clearly emphasized in the documentation. I believe the library should handle the parsing of extra spaces.