From 7af1c41b35ace042e77940c778332b0b94ce9568 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Mon, 5 Feb 2024 22:27:30 -0600 Subject: [PATCH] =?UTF-8?q?Fix=20line-splitting=20function=20(remove=20ext?= =?UTF-8?q?raneous=20=E2=80=9C:=E2=80=9D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vcarded.scm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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)))