mirror of
https://github.com/joho/godotenv.git
synced 2025-06-25 20:34:02 +00:00
Ignoring leading whitespace
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
This commit is contained in:
@ -5,8 +5,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var noopPresets = make(map[string]string)
|
||||
@ -355,6 +355,11 @@ func TestParsing(t *testing.T) {
|
||||
parseAndCompare(t, `KEY="`, "KEY", "\"")
|
||||
parseAndCompare(t, `KEY="value`, "KEY", "\"value")
|
||||
|
||||
// leading whitespace should be ignored
|
||||
parseAndCompare(t, " KEY =value", "KEY", "value")
|
||||
parseAndCompare(t, " KEY=value", "KEY", "value")
|
||||
parseAndCompare(t, "\tKEY=value", "KEY", "value")
|
||||
|
||||
// it 'throws an error if line format is incorrect' do
|
||||
// expect{env('lol$wut')}.to raise_error(Dotenv::FormatError)
|
||||
badlyFormattedLine := "lol$wut"
|
||||
@ -371,6 +376,10 @@ func TestLinesToIgnore(t *testing.T) {
|
||||
t.Error("Line with nothing but line break wasn't ignored")
|
||||
}
|
||||
|
||||
if !isIgnoredLine("\r\n") {
|
||||
t.Error("Line with nothing but windows-style line break wasn't ignored")
|
||||
}
|
||||
|
||||
if !isIgnoredLine("\t\t ") {
|
||||
t.Error("Line full of whitespace wasn't ignored")
|
||||
}
|
||||
|
Reference in New Issue
Block a user