Skip to content

Commit 5bbef66

Browse files
authored
Merge pull request #523 from bkeepers/preserve-linebreaks
Fix issue with repeated linebreaks when normalizing line endings
2 parents 79c0f1c + 19a7675 commit 5bbef66

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

Changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
[Unreleased changes](https://github.com/bkeepers/dotenv/compare/v3.1.6...main)
44

5+
## 3.1.7
6+
7+
* Fix issue with repeated linebreaks when normalizing line endings by @bkeepers in https://github.com/bkeepers/dotenv/pull/523
8+
9+
**Full Changelog**: https://github.com/bkeepers/dotenv/compare/v3.1.6...v3.1.7
10+
511
## 3.1.6
612

713
* Fix: Restore previous parser behavior of returning existing variables by @bkeepers in https://github.com/bkeepers/dotenv/pull/519

lib/dotenv/parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def call(...)
4343

4444
def initialize(string, overwrite: false)
4545
# Convert line breaks to same format
46-
@string = string.gsub(/[\n\r]+/, "\n")
46+
@string = string.gsub(/\r\n?/, "\n")
4747
@hash = {}
4848
@overwrite = overwrite
4949
end

lib/dotenv/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Dotenv
2-
VERSION = "3.1.6".freeze
2+
VERSION = "3.1.7".freeze
33
end

spec/dotenv/parser_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ def env(...)
158158
.to eql("foo" => "bar", "fizz" => "buzz")
159159
end
160160

161+
it "does not ignore empty lines in quoted string" do
162+
value = "a\n\nb\n\nc"
163+
expect(env("FOO=\"#{value}\"")).to eql("FOO" => value)
164+
end
165+
161166
it "ignores inline comments" do
162167
expect(env("foo=bar # this is foo")).to eql("foo" => "bar")
163168
end

0 commit comments

Comments
 (0)