Skip to content

Commit c261fb4

Browse files
fixup! src: improve node::Dotenv trimming
add check for when no value is present
1 parent e3ee074 commit c261fb4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/node_dotenv.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ void Dotenv::ParseContent(const std::string_view input) {
154154
key = content.substr(0, equal);
155155
content.remove_prefix(equal + 1);
156156
key = trim_spaces(key);
157+
158+
// If the value is not present (e.g. KEY=) set is to an empty string
159+
if (content.front() == '\n') {
160+
store_.insert_or_assign(std::string(key), "");
161+
continue;
162+
}
163+
157164
content = trim_spaces(content);
158165

159166
if (key.empty()) {

0 commit comments

Comments
 (0)