.
original commit: a8096f4985da40684712583aa6ed49c974a1d41f
This commit is contained in:
parent
38ad8e3b79
commit
2a9bb5235d
|
@ -73,6 +73,7 @@
|
||||||
|
|
||||||
(require (lib "unitsig.ss")
|
(require (lib "unitsig.ss")
|
||||||
(lib "match.ss")
|
(lib "match.ss")
|
||||||
|
(lib "string.ss")
|
||||||
"uri-codec-sig.ss")
|
"uri-codec-sig.ss")
|
||||||
|
|
||||||
(provide uri-codec@)
|
(provide uri-codec@)
|
||||||
|
@ -199,20 +200,25 @@
|
||||||
(define (form-urlencoded-decode str)
|
(define (form-urlencoded-decode str)
|
||||||
(decode form-urlencoded-decoding-vector str))
|
(decode form-urlencoded-decoding-vector str))
|
||||||
|
|
||||||
;; listof (cons string string) -> string
|
;; listof (cons symbol string) -> string
|
||||||
(define alist->form-urlencoded
|
(define alist->form-urlencoded
|
||||||
(match-lambda
|
(lambda (args)
|
||||||
[() ""]
|
(let* ([format-one
|
||||||
[((name . value))
|
(lambda (arg)
|
||||||
(string-append (form-urlencoded-encode name)
|
(let* ([name (car arg)]
|
||||||
"="
|
[value (cdr arg)])
|
||||||
(form-urlencoded-encode value))]
|
(string-append
|
||||||
[((name . value) . rest)
|
(form-urlencoded-encode (symbol->string name))
|
||||||
(string-append (form-urlencoded-encode name)
|
"="
|
||||||
"="
|
(form-urlencoded-encode value))))]
|
||||||
(form-urlencoded-encode value)
|
[strs (let loop ([args args])
|
||||||
"&"
|
(cond
|
||||||
(alist->form-urlencoded rest))]))
|
[(null? args) null]
|
||||||
|
[(null? (cdr args)) (list (format-one (car args)))]
|
||||||
|
[else (list* (format-one (car args))
|
||||||
|
"&"
|
||||||
|
(loop (cdr args)))]))])
|
||||||
|
(apply string-append strs))))
|
||||||
|
|
||||||
;; string -> listof (cons string string)
|
;; string -> listof (cons string string)
|
||||||
(define (form-urlencoded->alist str)
|
(define (form-urlencoded->alist str)
|
||||||
|
@ -223,7 +229,9 @@
|
||||||
#f
|
#f
|
||||||
(match (regexp-match-positions key-regexp str start)
|
(match (regexp-match-positions key-regexp str start)
|
||||||
[((start . end))
|
[((start . end))
|
||||||
(vector (form-urlencoded-decode (substring str start end))
|
(vector (let ([s (form-urlencoded-decode (substring str start end))])
|
||||||
|
(string-lowercase! s)
|
||||||
|
(string->symbol s))
|
||||||
(add1 end))]
|
(add1 end))]
|
||||||
[#f #f])))
|
[#f #f])))
|
||||||
(define (next-value str start)
|
(define (next-value str start)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user