Skip to content

Commit 12105d9

Browse files
committed
refactor: apply comment
1 parent 8a094b7 commit 12105d9

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

benchmark/fixtures/valid.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BASIC=basic
66

77
# previous line intentionally left blank
88
AFTER_LINE=after_line
9-
A=B=C
9+
A="B=C"
1010
EMPTY=
1111
EMPTY_SINGLE_QUOTES=''
1212
EMPTY_DOUBLE_QUOTES=""

src/node_dotenv.cc

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void Dotenv::ParseContent(const std::string_view input) {
149149
if (newline != std::string_view::npos) {
150150
content.remove_prefix(newline + 1);
151151
} else {
152-
content.remove_prefix(content.size());
152+
content = {};
153153
}
154154
continue;
155155
}
@@ -203,7 +203,7 @@ void Dotenv::ParseContent(const std::string_view input) {
203203
if (newline != std::string_view::npos) {
204204
content.remove_prefix(newline + 1);
205205
} else {
206-
content.remove_prefix(content.size());
206+
content = {};
207207
}
208208
continue;
209209
}
@@ -236,7 +236,7 @@ void Dotenv::ParseContent(const std::string_view input) {
236236
if (newline != std::string_view::npos) {
237237
content.remove_prefix(newline + 1);
238238
} else {
239-
content.remove_prefix(content.size());
239+
content = {};
240240
}
241241
continue;
242242
}
@@ -254,8 +254,7 @@ void Dotenv::ParseContent(const std::string_view input) {
254254
if (hash_character != std::string_view::npos) {
255255
value = content.substr(0, hash_character);
256256
}
257-
value = trim_spaces(value);
258-
store_.insert_or_assign(std::string(key), value);
257+
store_.insert_or_assign(std::string(key), trim_spaces(value));
259258
content.remove_prefix(newline + 1);
260259
} else {
261260
// In case the last line is a single key/value pair
@@ -265,14 +264,11 @@ void Dotenv::ParseContent(const std::string_view input) {
265264
if (hash_char != std::string_view::npos) {
266265
value = content.substr(0, hash_char);
267266
}
268-
value = trim_spaces(value);
269-
270-
store_.insert_or_assign(std::string(key), value);
271-
content.remove_prefix(content.size());
267+
store_.insert_or_assign(std::string(key), trim_spaces(value));
268+
content = {};
272269
}
273270

274-
value = trim_spaces(value);
275-
store_.insert_or_assign(std::string(key), value);
271+
store_.insert_or_assign(std::string(key), trim_spaces(value));
276272
}
277273
}
278274
}

test/fixtures/dotenv/valid.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BASIC=basic
66

77
# previous line intentionally left blank
88
AFTER_LINE=after_line
9-
A=B=C
9+
A="B=C"
1010
EMPTY=
1111
EMPTY_SINGLE_QUOTES=''
1212
EMPTY_DOUBLE_QUOTES=""

0 commit comments

Comments
 (0)