aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-08-07 14:03:59 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-08-07 14:03:59 +0200
commit7e2aaf5b3ac44eefbf8a8eb2124789b04a6f3b7f (patch)
treef532d66cc9a5e6ebe2c0c4351ea7b3da1359fe80
parentr:query now guaranteed string. (diff)
downloadcalp-7e2aaf5b3ac44eefbf8a8eb2124789b04a6f3b7f.tar.gz
calp-7e2aaf5b3ac44eefbf8a8eb2124789b04a6f3b7f.tar.xz
Fix parse-query.
-rw-r--r--module/server/util.scm22
1 files 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 #\&))))