1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// This file is part of helpers4.
// Copyright (C) 2025 baxyz
// SPDX-License-Identifier: LGPL-3.0-or-later
use parse_line;
/// Parses dotenv `content` into `(key, value)` pairs, in file order.
///
/// Blank lines, `#` comments and lines that are not valid `KEY=value` assignments are skipped.
/// Supported: an optional `export ` prefix, bare values (a `#` after whitespace starts a
/// comment), `"double quoted"` values with `\n \r \t \" \\` escapes and `'single quoted'`
/// literals. Values are single-line. A key assigned twice appears twice.
///
/// # Arguments
///
/// - `content` - The dotenv text to parse.
///
/// # Examples
///
/// ```
/// use helpers4::env::parse;
///
/// let vars = parse("# comment\nHOST=localhost\nexport NAME=\"my app\" # trailing\n");
/// assert_eq!(
/// vars,
/// vec![
/// ("HOST".to_string(), "localhost".to_string()),
/// ("NAME".to_string(), "my app".to_string()),
/// ]
/// );
/// ```