Fix line-splitting function (remove extraneous “:”)

This commit is contained in:
Jaidyn Ann 2024-02-05 22:27:30 -06:00
parent ff259fe683
commit 7af1c41b35

View File

@ -34,14 +34,18 @@
;; Splits a line into a cons of the property-string and value-string.
;; … basically splits the string along the first unescaped colon (:).
;; "apple\:berry:mom:dad" → ("apple\:berry" . "mom:dad")
(define (split-vcard-line line)
(let [(split (irregex-extract "(\\\\:|[^:])*" line))]
(if (>= (length split) 2)
(cons
(car split)
(reduce-right
;; Drop the values first char (redundant “:”) and concatenate the
;; rest of the string-parts which were erroneously split along “:”.
(string-drop (reduce-right
(lambda (a b) (string-concatenate (list a ":" b)))
"" (cdr split)))
"" (cdr split))
1))
#f)))