Skip to content

Commit

Permalink
Merge pull request #523 from bkeepers/preserve-linebreaks
Browse files Browse the repository at this point in the history
Fix issue with repeated linebreaks when normalizing line endings
  • Loading branch information
bkeepers authored Dec 18, 2024
2 parents 79c0f1c + 19a7675 commit 5bbef66
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

## 3.1.7

* Fix issue with repeated linebreaks when normalizing line endings by @bkeepers in https://github.com/bkeepers/dotenv/pull/523

**Full Changelog**: https://github.com/bkeepers/dotenv/compare/v3.1.6...v3.1.7

## 3.1.6

* Fix: Restore previous parser behavior of returning existing variables by @bkeepers in https://github.com/bkeepers/dotenv/pull/519
Expand Down
2 changes: 1 addition & 1 deletion lib/dotenv/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def call(...)

def initialize(string, overwrite: false)
# Convert line breaks to same format
@string = string.gsub(/[\n\r]+/, "\n")
@string = string.gsub(/\r\n?/, "\n")
@hash = {}
@overwrite = overwrite
end
Expand Down
2 changes: 1 addition & 1 deletion lib/dotenv/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Dotenv
VERSION = "3.1.6".freeze
VERSION = "3.1.7".freeze
end
5 changes: 5 additions & 0 deletions spec/dotenv/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ def env(...)
.to eql("foo" => "bar", "fizz" => "buzz")
end

it "does not ignore empty lines in quoted string" do
value = "a\n\nb\n\nc"
expect(env("FOO=\"#{value}\"")).to eql("FOO" => value)
end

it "ignores inline comments" do
expect(env("foo=bar # this is foo")).to eql("foo" => "bar")
end
Expand Down

0 comments on commit 5bbef66

Please sign in to comment.