Fix line-splitting function (remove extraneous “:”)
This commit is contained in:
parent
ff259fe683
commit
7af1c41b35
|
@ -34,14 +34,18 @@
|
||||||
|
|
||||||
;; Splits a line into a cons of the property-string and value-string.
|
;; Splits a line into a cons of the property-string and value-string.
|
||||||
;; … basically splits the string along the first unescaped colon (:).
|
;; … basically splits the string along the first unescaped colon (:).
|
||||||
|
;; "apple\:berry:mom:dad" → ("apple\:berry" . "mom:dad")
|
||||||
(define (split-vcard-line line)
|
(define (split-vcard-line line)
|
||||||
(let [(split (irregex-extract "(\\\\:|[^:])*" line))]
|
(let [(split (irregex-extract "(\\\\:|[^:])*" line))]
|
||||||
(if (>= (length split) 2)
|
(if (>= (length split) 2)
|
||||||
(cons
|
(cons
|
||||||
(car split)
|
(car split)
|
||||||
(reduce-right
|
;; Drop the value’s 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)))
|
(lambda (a b) (string-concatenate (list a ":" b)))
|
||||||
"" (cdr split)))
|
"" (cdr split))
|
||||||
|
1))
|
||||||
#f)))
|
#f)))
|
||||||
|
|
||||||
|
|
||||||
|
|
Ŝarĝante…
Reference in New Issue