aboutsummaryrefslogtreecommitdiff
path: root/module/web/uri-query.scm
blob: e7cc627c1502d461ffcc1f17f6b5fb181eecaca8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(define-module (web uri-query)
  :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 (with-output-to-string (lambda () (write (cdr p)))))))
        parameters)
   "&"))