aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 #\&))))