diff --git a/vcarded.scm b/vcarded.scm index 0a40bd4..cd0dc8d 100644 --- a/vcarded.scm +++ b/vcarded.scm @@ -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 - (lambda (a b) (string-concatenate (list a ":" b))) - "" (cdr split))) + ;; 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))) + "" (cdr split)) + 1)) #f)))