GeezerVison is showing github.com — src: fix env-file flag to ignore spaces before quotes · nodejs/node@c53cf44
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node_dotenv.cc +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -129,6 +129,7 @@ void Dotenv::ParseContent(const std::string_view input) { |
129 | 129 | key = content.substr(0, equal); |
130 | 130 | content.remove_prefix(equal + 1); |
131 | 131 | key = trim_spaces(key); |
| 132 | + content = trim_spaces(content); |
132 | 133 |
|
133 | 134 | if (key.empty()) { |
134 | 135 | break; |
|
Collapse file
Copy file name to clipboardExpand all lines: test/fixtures/dotenv/valid.env +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -38,6 +38,7 @@ RETAIN_INNER_QUOTES={"foo": "bar"} |
38 | 38 | RETAIN_INNER_QUOTES_AS_STRING='{"foo": "bar"}' |
39 | 39 | RETAIN_INNER_QUOTES_AS_BACKTICKS=`{"foo": "bar's"}` |
40 | 40 | TRIM_SPACE_FROM_UNQUOTED= some spaced out string |
| 41 | +SPACE_BEFORE_DOUBLE_QUOTES= "space before double quotes" |
41 | 42 | |
42 | 43 | SPACED_KEY = parsed |
43 | 44 | EDGE_CASE_INLINE_COMMENTS="VALUE1" # or "VALUE2" or "VALUE3" |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-dotenv.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -80,3 +80,5 @@ assert.strictEqual(process.env.DONT_EXPAND_UNQUOTED, 'dontexpand\\nnewlines'); |
80 | 80 | assert.strictEqual(process.env.DONT_EXPAND_SQUOTED, 'dontexpand\\nnewlines'); |
81 | 81 | // Ignore export before key |
82 | 82 | assert.strictEqual(process.env.EXPORT_EXAMPLE, 'ignore export'); |
| 83 | +// Ignore spaces before double quotes to avoid quoted strings as value |
| 84 | +assert.strictEqual(process.env.SPACE_BEFORE_DOUBLE_QUOTES, 'space before double quotes'); |