diff options
Diffstat (limited to 'module/server/util.scm')
-rw-r--r-- | module/server/util.scm | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/module/server/util.scm b/module/server/util.scm index 7f5ebdbe..ada4f266 100644 --- a/module/server/util.scm +++ b/module/server/util.scm @@ -1,16 +1,17 @@ (define-module (server util) :use-module (util) - :use-module (srfi srfi-1)) + :use-module (srfi srfi-1) + :use-module (web uri)) (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 #\&)))) + (unless (or (not query-string) (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 (uri-decode (substring str 0 idx))) + (define val (uri-decode (substring str (1+ idx)))) + (cons* (-> key string->symbol symbol->keyword) val list)) + '() (string-split query-string #\&)))) |