Skip to content

Commit

Permalink
'empty' must be quoted to be valid string field value (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
burmajam authored Jul 12, 2023
1 parent f038f6f commit 309cc24
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.11.5

- Default `empty` value in fields must be quoted to be valid string field value.

## v0.11.4

- Handle empty strings in tag/field values
Expand Down
2 changes: 1 addition & 1 deletion lib/fluxter/packet.ex
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ defmodule Fluxter.Packet do
val
|> String.trim()
|> case do
"" -> "empty"
"" -> "\"empty\""
other -> [?\", escape(other, '"'), ?\"]
end

Expand Down
4 changes: 2 additions & 2 deletions test/fluxter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ defmodule FluxterTest do

test "empty string field" do
TestFluxter.write("foo", "")
assert_receive {:echo, "foo value=empty"}
assert_receive {:echo, "foo value=\"empty\""}
end

test "only spaces in field" do
TestFluxter.write("foo", " ")
assert_receive {:echo, "foo value=empty"}
assert_receive {:echo, "foo value=\"empty\""}
end

test "atom field" do
Expand Down

0 comments on commit 309cc24

Please sign in to comment.