forked from coop-cloud-mirrors/godotenv
allow empty_var
This commit is contained in:
21
godotenv.go
21
godotenv.go
@ -212,20 +212,23 @@ func parseLine(line string) (key string, value string, err error) {
|
||||
|
||||
// Parse the value
|
||||
value = splitString[1]
|
||||
|
||||
// trim
|
||||
value = strings.Trim(value, " ")
|
||||
|
||||
// check if we've got quoted values
|
||||
first := string(value[0:1])
|
||||
last := string(value[len(value)-1:])
|
||||
if first == last && strings.ContainsAny(first, `"'`) {
|
||||
// pull the quotes off the edges
|
||||
value = strings.Trim(value, `"'`)
|
||||
if value != "" {
|
||||
first := string(value[0:1])
|
||||
last := string(value[len(value)-1:])
|
||||
if first == last && strings.ContainsAny(first, `"'`) {
|
||||
// pull the quotes off the edges
|
||||
value = strings.Trim(value, `"'`)
|
||||
|
||||
// expand quotes
|
||||
value = strings.Replace(value, `\"`, `"`, -1)
|
||||
// expand newlines
|
||||
value = strings.Replace(value, `\n`, "\n", -1)
|
||||
// expand quotes
|
||||
value = strings.Replace(value, `\"`, `"`, -1)
|
||||
// expand newlines
|
||||
value = strings.Replace(value, `\n`, "\n", -1)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
Reference in New Issue
Block a user