@@ -145,7 +145,13 @@ void Dotenv::ParseContent(const std::string_view input) {
145145    //  If there is no equal character, then ignore everything
146146    auto  equal = content.find (' =' 
147147    if  (equal == std::string_view::npos) {
148-       break ;
148+       auto  newline = content.find (' \n ' 
149+       if  (newline != std::string_view::npos) {
150+         content.remove_prefix (newline + 1 );
151+       } else  {
152+         content.remove_prefix (content.size ());
153+       }
154+       continue ;
149155    }
150156
151157    key = content.substr (0 , equal);
@@ -195,7 +201,9 @@ void Dotenv::ParseContent(const std::string_view input) {
195201        store_.insert_or_assign (std::string (key), multi_line_value);
196202        auto  newline = content.find (' \n ' 1 );
197203        if  (newline != std::string_view::npos) {
198-           content.remove_prefix (newline);
204+           content.remove_prefix (newline + 1 );
205+         } else  {
206+           content.remove_prefix (content.size ());
199207        }
200208        continue ;
201209      }
@@ -216,7 +224,7 @@ void Dotenv::ParseContent(const std::string_view input) {
216224        if  (newline != std::string_view::npos) {
217225          value = content.substr (0 , newline);
218226          store_.insert_or_assign (std::string (key), value);
219-           content.remove_prefix (newline);
227+           content.remove_prefix (newline +  1 );
220228        }
221229      } else  {
222230        //  Example: KEY="value"
@@ -226,8 +234,11 @@ void Dotenv::ParseContent(const std::string_view input) {
226234        //  since there could be newline characters inside the value.
227235        auto  newline = content.find (' \n ' 1 );
228236        if  (newline != std::string_view::npos) {
229-           content.remove_prefix (newline);
237+           content.remove_prefix (newline + 1 );
238+         } else  {
239+           content.remove_prefix (content.size ());
230240        }
241+         continue ;
231242      }
232243    } else  {
233244      //  Regular key value pair.
@@ -243,11 +254,21 @@ void Dotenv::ParseContent(const std::string_view input) {
243254        if  (hash_character != std::string_view::npos) {
244255          value = content.substr (0 , hash_character);
245256        }
246-         content.remove_prefix (newline);
257+         value = trim_spaces (value);
258+         store_.insert_or_assign (std::string (key), value);
259+         content.remove_prefix (newline + 1 );
247260      } else  {
248261        //  In case the last line is a single key/value pair
249262        //  Example: KEY=VALUE (without a newline at the EOF)
250-         value = content.substr (0 );
263+         value = content;
264+         auto  hash_char = value.find (' #' 
265+         if  (hash_char != std::string_view::npos) {
266+           value = content.substr (0 , hash_char);
267+         }
268+         value = trim_spaces (value);
269+ 
270+         store_.insert_or_assign (std::string (key), value);
271+         content.remove_prefix (content.size ());
251272      }
252273
253274      value = trim_spaces (value);
0 commit comments