Skip to content

Commit af11847

Browse files
committed
Ignore empty lines
1 parent 91bac50 commit af11847

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/tick/alpha/ical.clj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,10 @@
262262
(defn unfolding-line-seq*
263263
[^java.io.BufferedReader rdr hold]
264264
(if-let [line (.readLine rdr)]
265-
(if (= (.charAt line 0) \space)
266-
(recur rdr (conj hold (.substring line 1)))
267-
(cons (str/join hold) (lazy-seq (unfolding-line-seq* rdr [line]))))
265+
(cond
266+
(.isEmpty line) (recur rdr hold)
267+
(= (.charAt line 0) \space) (recur rdr (conj hold (.substring line 1)))
268+
:else (cons (str/join hold) (lazy-seq (unfolding-line-seq* rdr [line]))))
268269
[(str/join hold)]))
269270

270271
(defn unfolding-line-seq [^java.io.BufferedReader rdr]

test/tick/alpha/ical_test.clj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,18 @@
6060
ical/unfolding-line-seq
6161
first
6262
ical/line->contentline)))))
63+
64+
(def multi-with-empty
65+
"X-APPLE-STRUCTURED-LOCATION;VALUE=URI;X-SOME-HEADER-BREAKING-SOMEWHERE-AT-
66+
75=foobar;X-TITLE=Some Place:geo:44.815458,20.462758
67+
68+
FOO:bar")
69+
70+
(deftest parse-line-ignore-empty-test
71+
(testing "Empty lines are ignored"
72+
(is (= ["X-APPLE-STRUCTURED-LOCATION;VALUE=URI;X-SOME-HEADER-BREAKING-SOMEWHERE-AT-75=foobar;X-TITLE=Some Place:geo:44.815458,20.462758"
73+
"FOO:bar"]
74+
(-> multi-with-empty
75+
char-array
76+
io/reader
77+
ical/unfolding-line-seq)))))

0 commit comments

Comments
 (0)