aboutsummaryrefslogtreecommitdiff
path: root/module/web/uri-query.scm
blob: adf9980375537bd0787689bedce874240ed6f26c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(define-module (web uri-query)
  :use-module ((hnh util) :select (->quoted-string))
  :use-module ((web uri) :select (uri-encode))
  :export (encode-query-parameters)
  )

;; TODO why this format for values?
;; TODO why aren't we encoding the keys?
;; TODO why isn't this in the same module as `parse-query'?
;; TODO why isn't this on the same format as `parse-query'?

(define (encode-query-parameters parameters)
  (string-join
   (map (lambda (p)
          (format #f "~a=~a"
                  (car p)
                  (uri-encode (->quoted-string (cdr p)))))
        parameters)
   "&"))