original commit: 282f99491878fb8b3fc512a0e3217c1ec67027ae
This commit is contained in:
Robby Findler 2004-03-21 02:37:42 +00:00
parent b80094cf12
commit 41243281d4

View File

@ -13,21 +13,58 @@
(define (string->url/vec str) (define (string->url/vec str)
(let ([res (string->url str)]) (let ([res (string->url str)])
(vector (url-scheme res) (vector (url-scheme res)
(url-user res)
(url-host res) (url-host res)
(url-port res) (url-port res)
(url-path res) (map (lambda (x) (if (string? x)
(url-params res) x
(vector (path/param-path x) (path/param-param x))))
(url-path res))
(url-query res) (url-query res)
(url-fragment res) (url-fragment res))))
(url/user-user res)))) (define (url/vec->string vec)
(test vec string->url/vec str)) (url->string
(make-url
(vector-ref vec 0)
(vector-ref vec 1)
(vector-ref vec 2)
(vector-ref vec 3)
(map (lambda (x) (if (string? x)
x
(make-path/param (vector-ref x 0) (vector-ref x 1))))
(vector-ref vec 4))
(vector-ref vec 5)
(vector-ref vec 6))))
(test-s->u (vector "http" "www.google.com" #f '() #f #f #f #f) (test vec string->url/vec str)
(test str url/vec->string vec))
(test-s->u (vector "http" #f "www.google.com" #f '() #f #f)
"http://www.google.com/") "http://www.google.com/")
(test-s->u (vector "http" "www.google.com" #f (list "a" "b" "c") #f #f #f #f) (test-s->u (vector "http" #f "www.google.com" #f (list "a" "b" "c") #f #f)
"http://www.google.com/a/b/c")) "http://www.google.com/a/b/c")
(test-s->u (vector "http" "robby" "www.google.com" #f (list "a" "b" "c") #f #f)
"http://robby@www.google.com/a/b/c")
(test-s->u (vector "http" #f "www.google.com" 8080 (list "a" "b" "c") #f #f)
"http://www.google.com:8080/a/b/c")
(test-s->u (vector "http" #f "www.google.com" #f (list "a" "b" "c") #f "joe")
"http://www.google.com/a/b/c#joe")
(test-s->u (vector "http" #f "www.google.com" #f (list "a" "b" "c") "tim" #f)
"http://www.google.com/a/b/c?tim")
(test-s->u (vector "http" #f "www.google.com" #f (list "a" "b" "c") "tim" "joe")
"http://www.google.com/a/b/c?tim#joe")
(test-s->u (vector "http" #f "www.google.com" #f (list "a" "b" #("c" "b")) #f #f)
"http://www.google.com/a/b/c;b")
(test-s->u (vector "http" #f "www.google.com" #f (list #("a" "x") "b" #("c" "b")) #f #f)
"http://www.google.com/a;x/b/c;b")
(report-errs) ;; test unquoting for %
(test-s->u (vector "http" #f "www.google.com" #f (list "a" "b" "c") "ti#m" "jo e")
"http://www.google.com/a/b/c?ti%23m#jo%20e")
(test-s->u (vector "http" #f "www.google.com" #f (list #("a " " a") " b " " c ") #f #f)
"http://www.google.com/a ; a/ b / c ")
(test-s->u (vector "http" "robb y" "www.google.com" #f '() #f #f)
"http://robb%20y@www.google.com/"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;