Skip to content

Commit ca720e0

Browse files
update from feedback
1 parent cf3b8ab commit ca720e0

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

src/node_dotenv.cc

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,23 @@ void Dotenv::ParseContent(const std::string_view input) {
138138
// Example:
139139
// # This is a comment
140140
if (content.front() == '\n' || content.front() == '#') {
141-
auto newline = content.find('\n');
142-
if (newline != std::string_view::npos) {
143-
content.remove_prefix(newline + 1);
144-
// Trim spaces after skipping comments or empty lines to handle
145-
// cases where there might be trailing whitespace
146-
content = trim_spaces(content);
147-
continue;
141+
// Check if the first character of the content is a newline or a hash
142+
if (content.front() == '\n') {
143+
// If the first character is a newline, remove it
144+
content.remove_prefix(1);
148145
} else {
149-
// If no newline is found, we've reached the end of content
150-
// Example: #ABC=1
151-
break;
146+
// If the first character is a hash, find the next newline character
147+
auto newline = content.find('\n');
148+
if (newline != std::string_view::npos) {
149+
// If a newline is found, remove the comment line including the
150+
// newline character
151+
content.remove_prefix(newline + 1);
152+
}
152153
}
154+
155+
// Skip the remaining code in the loop and continue with the next
156+
// iteration
157+
continue;
153158
}
154159

155160
// Find the next equals sign or newline in a single pass

0 commit comments

Comments
 (0)