merging a PR from the official dotenv repo that addresses the newline issue

This commit is contained in:
Erin O'Connell
2017-11-19 15:50:05 -07:00
parent aac0ef92a5
commit ddde2b227e
+2 -8
View File
@@ -97,16 +97,10 @@ def dotenv_values(dotenv_path):
def parse_dotenv(dotenv_path):
with open(dotenv_path) as f:
for line in f:
line = line.strip()
if not line or line.startswith('#') or '=' not in line:
continue
k, v = line.split('=', 1)
# Remove any leading and trailing spaces in key, value
k, v = k.strip(), v.strip()
for k, v in re.findall('^\s*(\w*)\s*=\s*("[^"]*"|[^\s]*)\s*$', f.read(), flags=re.MULTILINE):
if len(v) > 0:
quoted = v[0] == v[len(v) - 1] in ['"', "'"]
if quoted:
v = decode_escaped(v[1:-1])