motdotla / dotenv

Loads environment variables from .env for nodejs projects.
https://www.dotenvx.com
BSD 2-Clause "Simplified" License
19.26k stars 860 forks source link

Supporting Escape Sequences #711

Open bd82 opened 1 year ago

bd82 commented 1 year ago

Hello @motdotla and thank you for creating dotenv nodejs library 👍

Feature Request

Could dotenv nodejs library support escape sequences (e.g \" \t) ?

At the minimum can it be aligned with the Ruby dotenv library?

Would a PR which aligns with the Ruby library be welcome?

Context

I've noticed some implementations of dotenv support character escapes and some do not. Also there does not seem to be an official specification anywhere for dotenv. This is causing issues when we need to use the same .env files in multiple runtimes.

Is the Ruby library the original implementation and thus also used as the pseudo specification?

Examples of escape handling in different dotenv libraries

Ruby Library

Elixir Library escaping specs

Python Library

ritschwumm commented 1 year ago

interestingly, the LINE regexp already does understand backslashed in front of single quote, double quote and backtick...

motdotla commented 1 week ago

looking at this again. i will give it a fresh look in relation to dotenvx