updated test and docs for url->string
and srtung->url
Test and document host-plus-absoulte-path constraint on string forms.
This commit is contained in:
parent
a0b5403bd8
commit
6b522f50da
|
@ -171,7 +171,8 @@ scheme @racket["http"].}
|
||||||
|
|
||||||
Generates a string corresponding to the contents of a @racket[url]
|
Generates a string corresponding to the contents of a @racket[url]
|
||||||
struct. For a @racket["file:"] URL, the URL must not be relative, and
|
struct. For a @racket["file:"] URL, the URL must not be relative, and
|
||||||
the result always starts @litchar{file://}.
|
the result always starts @litchar{file://}. For a URL with a host,
|
||||||
|
user, or port, its path must be either absolute or empty.
|
||||||
|
|
||||||
The @racket[url->string] procedure uses
|
The @racket[url->string] procedure uses
|
||||||
@racket[alist->form-urlencoded] when formatting the query, so it is
|
@racket[alist->form-urlencoded] when formatting the query, so it is
|
||||||
|
|
|
@ -91,6 +91,11 @@
|
||||||
(test-s->u #("http" #f "www.drscheme.org" #f #t (#("a" "x") #("b") #("c" "b")) () #f)
|
(test-s->u #("http" #f "www.drscheme.org" #f #t (#("a" "x") #("b") #("c" "b")) () #f)
|
||||||
"http://www.drscheme.org/a;x/b/c;b")
|
"http://www.drscheme.org/a;x/b/c;b")
|
||||||
|
|
||||||
|
;; Allow empty port spec
|
||||||
|
(test #("http" #f "www.drscheme.org" #f #t (#("a")) () #f)
|
||||||
|
url->vec
|
||||||
|
(string->url "http://www.drscheme.org:/a"))
|
||||||
|
|
||||||
;; Test IPv6 literal addresses, which are written with "[...]" around
|
;; Test IPv6 literal addresses, which are written with "[...]" around
|
||||||
;; an address that contains ":"s:
|
;; an address that contains ":"s:
|
||||||
(test-s->u #("http" #f "::1" #f #t (#("a") #("b") #("c")) () "joe")
|
(test-s->u #("http" #f "::1" #f #t (#("a") #("b") #("c")) () "joe")
|
||||||
|
@ -158,6 +163,18 @@
|
||||||
(string->url "a*b://www.foo.com/") =error> url-exception?
|
(string->url "a*b://www.foo.com/") =error> url-exception?
|
||||||
(string->url "a b://www.foo.com/") =error> url-exception?)
|
(string->url "a b://www.foo.com/") =error> url-exception?)
|
||||||
|
|
||||||
|
;; test relatve path after host
|
||||||
|
(test
|
||||||
|
(string->url "http://www.foo.com:oops/") =error> url-exception?
|
||||||
|
(string->url "http://www.foo.com:0oops/") =error> url-exception?
|
||||||
|
|
||||||
|
;; Empty "relative" path is ok with host:
|
||||||
|
(url->string (url "http" #f "www.drscheme.org" #f #f (list) (list) #f))
|
||||||
|
=> "http://www.drscheme.org"
|
||||||
|
;; Non-empty "relative" path is not ok with host:
|
||||||
|
(url->string (url "http" #f "www.drscheme.org" #f #f (list (path/param "a" (list))) (list) #f))
|
||||||
|
=error> exn:fail:contract?)
|
||||||
|
|
||||||
;; test file: urls
|
;; test file: urls
|
||||||
(test-s->u #("file" #f "" #f #t (#("abc") #("def.html")) () #f)
|
(test-s->u #("file" #f "" #f #t (#("abc") #("def.html")) () #f)
|
||||||
"file:///abc/def.html")
|
"file:///abc/def.html")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user