Commit Graph

57 Commits (3a7a19020151b45a29896c9142723efe5b11a061)

Author SHA1 Message Date
柚子uccs 3a7a190201
fix: if a line contains multiple # characters, there will be issues w… (#238)
* fix: if a line contains multiple # characters, there will be issues when traversing from back to front

* fix: typo
2024-12-16 15:14:19 +11:00
Andrey Novikov a7f6c4c583
Re-add global env variable substitution (#227)
Co-authored-by: Stanislau Arsoba <sarsoba@klika-tech.com>
2024-11-01 09:24:06 +11:00
Chris Jones 193c9aba29
Add whitespace tests. (#210) 2023-04-20 10:52:14 +10:00
John Barton 3fc4292b58
Fix bug where internal unquoted whitespace truncates values (#205)
* Add tests to cover the regression reported in #204

* Add a comment on regex for clarity

* Remove some old code that wasn't doing anything

* Push _all_ parse code into the parser and get tests calling live code

* Add some newline specific tests

* Add some YAML tests for the newline/space split bug

* Fix incorrect terminating of lines on whitespace

* Fix most of the parser regressions

* Bring back FOO.BAR names

* remove some commented out code
2023-02-06 08:47:38 +11:00
John Barton cc9e9b7de7
Multiline string support (#156)
* refactor dotenv parser in order to support multi-line variable values declaration

Signed-off-by: x1unix <denis0051@gmail.com>

* Add multi-line var values test case and update comment test

Signed-off-by: x1unix <denis0051@gmail.com>

* Expand fixture tests to include multiline strings

* Update go versions to test against

* Switch to GOINSECURE for power8 CI task

* When tests fail, show source version of string (inc special chars)

* Update parser.go

Co-authored-by: Austin Sasko <austintyler0239@yahoo.com>

* Fix up bad merge

* Add a full fixture for comments for extra piece of mind

* Fix up some lint/staticcheck recommendations

* Test against go 1.19 too

Signed-off-by: x1unix <denis0051@gmail.com>
Co-authored-by: x1unix <denis0051@gmail.com>
Co-authored-by: Austin Sasko <austintyler0239@yahoo.com>
2023-01-27 13:14:16 +11:00
Oleksandr Redko e74c6cadd5
Fix typos in comments and extend README (#177) 2022-04-25 14:35:55 +10:00
Andre Soares 6e653f9adf add newline back 2020-06-26 15:39:50 -03:00
Andre Soares 29b5be9cdc Rename and implement int-able without quotes 2020-06-26 15:22:04 -03:00
John Barton 61baafa627
Merge branch 'master' into ignore-leading-whitespace 2019-02-04 15:28:23 +11:00
Dave Henderson 263a1dda9d
Support key names beginning with 'export'
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
2019-02-03 23:11:51 -05:00
Dave Henderson 79711eebaf
Ignoring leading whitespace
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
2019-02-03 22:39:38 -05:00
Lucas Tétreault 2d8b3aab88 feat(Expand Variables): Custom variable expansion instead of Go's os.Expand
Copy over the tests from https://github.com/bkeepers/dotenv/blob/master/spec/dotenv/parser_spec.rb
related to expanding variables and implement the required changes. I also realized as part of this
that this implementation was not handling values in single quotes properly (e.g.: not the same was
as the ruby package mentionned) so that has been fixed as well along with the related tests.

Fixes: #52
2018-09-11 00:55:10 -06:00
Takumasa Sakao 2707e9ff66 Fix test, `$` should not be escaped 2017-11-20 23:41:46 +09:00
Takumasa Sakao 33977c2d8d Add test for substitutions 2017-11-20 23:20:19 +09:00
Takumasa Sakao 9be76b3741 Pass envMap to parseLine & parseValue 2017-11-20 22:21:39 +09:00
John Barton (joho) 05be8ccbf7 Try and replicate reported bug #45 2017-11-10 10:38:18 +11:00
Alex Quick 3dd2dbe832 sort output of Write/Marshal 2017-09-16 18:02:27 -04:00
Alex Quick 9f04f40640 Be more careful with TestRoundtrip 2017-09-16 17:55:04 -04:00
Alex Quick b1bb9d9fc3 rename WriteString/ReadString to Marshal/Unmarshal 2017-09-14 00:24:22 -04:00
Alex Quick 5d289f4405 escape some other bash-y special chars ($!) 2017-09-13 23:13:08 -04:00
Alex Quick 88e7c8bd35 support for writing envs out in dotenv format 2017-09-13 23:13:08 -04:00
John Barton c9360df4d1 Merge pull request #34 from alexquick/fix-parsing-issues
Fix some small parsing bugs
2017-08-22 14:21:26 +10:00
Paul Annesley ebf1036af6 Parse(io.Reader) => map[string]string 2017-08-06 17:34:10 +10:00
Alex Quick a905e99577 fix panic with `"` as the value 2017-07-16 18:43:49 -04:00
Alex Quick 6f30f0c011 support for equals in yaml-style lines 2017-07-16 17:25:28 -04:00
Alex Quick 84bf91f40e rudimentry support for nested quotes 2017-07-16 17:24:36 -04:00
Alex Quick b9324c6f3c handle escaping more comprehensively 2017-07-16 17:15:29 -04:00
John Barton (joho) cd1272609d Add failing test for override of empty var 2017-03-28 11:39:40 +11:00
Oenning a42a65518c allow empty_var 2017-03-22 13:05:44 +00:00
Matias Anaya 6a1233b2f6 Fix quoted values check 2017-03-21 19:04:19 +11:00
Martin Milata 861984c215 Don't hide line parsing errors 2016-12-12 14:43:30 +01:00
Martin Milata 0ff0c0fc7a Propagate errors encountered when reading file 2016-12-12 14:41:36 +01:00
Josh Mervine 008304c688 adding Overload method 2015-09-05 08:59:08 -07:00
John Barton (joho) 8350eb932e Remove commented out code and go fmt tests. 2014-07-14 19:36:35 +10:00
David Bochenski bdacd70f4c fixup 2014-07-10 10:14:38 +01:00
David Bochenski ae0bc4ea3c Fix remaining failing test on windows 2014-07-09 15:35:36 +01:00
John Barton 3c13a80fe1 Merge pull request #3 from ys/feature/accept-equals-in-values
Use SplitN instead of split
2014-03-10 14:25:32 +11:00
Yannick Schutz 7e3e1e2c6c Use SplitN instead of split 2014-03-07 23:21:31 +01:00
mattn c0dce90b3c FOO=BAR= should be "FOO" = "BAR=" 2013-11-18 18:46:24 +09:00
John Barton (joho) 6e333bd708 add godotenv.Read() which returns a map rather than calling os.Setenv 2013-09-04 12:40:57 +10:00
John Barton (joho) 9ec71cc6c8 Make sure we don't overwrite existing ENV vars. 2013-07-31 14:25:10 +10:00
John Barton (joho) 9d9f6ccb57 Make Load() without args open .env by default 2013-07-31 13:51:59 +10:00
John Barton (joho) ac58adf673 Get the code running against all fixtures. 2013-07-31 13:39:59 +10:00
John Barton (joho) 9b4bbb98c3 Clear the env at the start of each integration test. 2013-07-31 12:57:44 +10:00
John Barton (joho) 9001b88250 Ignore comment lines and lines full o' whitespace. 2013-07-31 12:37:08 +10:00
John Barton (joho) 48ca995c3b Add some more tests. 2013-07-31 12:28:41 +10:00
John Barton (joho) 74ec3a085f Handle quoted hashes "properly"
Read: not prettily or robustly.
2013-07-31 12:24:03 +10:00
John Barton (joho) aa6e870b57 Red, green, rinse repeat. 2013-07-31 12:10:31 +10:00
John Barton (joho) a37b438d54 Start trying to do comments/quoting properly. 2013-07-31 11:48:10 +10:00
John Barton (joho) b3b488372f Mark out the rest of my todo list in the test file. 2013-07-30 18:44:17 +10:00