From 7e2aaf5b3ac44eefbf8a8eb2124789b04a6f3b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 7 Aug 2020 14:03:59 +0200 Subject: Fix parse-query. --- module/server/util.scm | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/module/server/util.scm b/module/server/util.scm index f6110952..7f5ebdbe 100644 --- a/module/server/util.scm +++ b/module/server/util.scm @@ -2,13 +2,15 @@ :use-module (util) :use-module (srfi srfi-1)) -(define-public (parse-query query) - (when query - (fold (lambda (str list) - ;; only split on the first equal. - ;; Does HTTP allow multiple equal signs in a data field? - (define idx (string-index str #\=)) - (define key (substring str 0 idx)) - (define val (substring str (1+ idx))) - (cons* (-> key string->symbol symbol->keyword) val list)) - '() (string-split query #\&)))) + +(define-public (parse-query query-string) + (unless (string-null? query-string) + (fold (lambda (str list) + ;; only split on the first equal. + ;; Does HTTP allow multiple equal signs in a data field? + ;; NOTE that this fails if str lacks an equal sign. + (define idx (string-index str #\=)) + (define key (substring str 0 idx)) + (define val (substring str (1+ idx))) + (cons* (-> key string->symbol symbol->keyword) val list)) + '() (string-split query-string #\&)))) -- cgit v1.2.3