Skip to content

Commit 5eff71c

Browse files
update from feedback
1 parent 2e3834d commit 5eff71c

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
@@ -140,18 +140,23 @@ void Dotenv::ParseContent(const std::string_view input) {
140140
// Example:
141141
// # This is a comment
142142
if (content.front() == '\n' || content.front() == '#') {
143-
auto newline = content.find('\n');
144-
if (newline != std::string_view::npos) {
145-
content.remove_prefix(newline + 1);
146-
// Trim spaces after skipping comments or empty lines to handle
147-
// cases where there might be trailing whitespace
148-
content = trim_spaces(content);
149-
continue;
143+
// Check if the first character of the content is a newline or a hash
144+
if (content.front() == '\n') {
145+
// If the first character is a newline, remove it
146+
content.remove_prefix(1);
150147
} else {
151-
// If no newline is found, we've reached the end of content
152-
// Example: #ABC=1
153-
break;
148+
// If the first character is a hash, find the next newline character
149+
auto newline = content.find('\n');
150+
if (newline != std::string_view::npos) {
151+
// If a newline is found, remove the comment line including the
152+
// newline character
153+
content.remove_prefix(newline + 1);
154+
}
154155
}
156+
157+
// Skip the remaining code in the loop and continue with the next
158+
// iteration
159+
continue;
155160
}
156161

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

0 commit comments

Comments
 (0)