Tests and docs for an IPv6 literal address as host in a URL

This commit is contained in:
Matthew Flatt 2016-04-16 21:27:22 -06:00
parent 053ca45b22
commit a0b5403bd8
2 changed files with 21 additions and 4 deletions

View File

@ -143,9 +143,11 @@ the path.
@history[#:changed "6.3.0.1" @elem{Changed handling of @litchar{file:}
URLs when the value of
@racket[file-url-path-convention-type]
is @racket['windows].}]
@history[#:changed "6.4.0.7" @elem{Use more specific regexp for
input contract.}]}
is @racket['windows].}
#:changed "6.4.0.7" @elem{Use more specific regexp for
input contract.}
#:changed "6.5.0.3" @elem{Support a host as an IPv6 literal address
as written in @litchar{[}...@litchar{]}.}]}
@defproc[(combine-url/relative [base url?] [relative string?]) url?]{
@ -178,7 +180,10 @@ determining the association separator. The default is to separate
associations with a @litchar{&}.
The encoding of path segments and fragment is sensitive to the
@racket[current-url-encode-mode] parameter.}
@racket[current-url-encode-mode] parameter.
@history[#:changed "6.5.0.3" @elem{Support a host as an IPv6 literals addresses
by writing the address in @litchar{[}...@litchar{]}.}]}
@defproc[(path->url [path (or/c path-string? path-for-some-system?)])

View File

@ -91,6 +91,18 @@
(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")
;; Test IPv6 literal addresses, which are written with "[...]" around
;; an address that contains ":"s:
(test-s->u #("http" #f "::1" #f #t (#("a") #("b") #("c")) () "joe")
"http://[::1]/a/b/c#joe")
;; This random address came from the Wikipedia page in IPv6:
(test-s->u #("http" #f "2001:0db8:85a3:0000:0000:8a2e:0370:7334" #f #t (#("a") #("b") #("c")) () "joe")
"http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]/a/b/c#joe")
(test "http://[::1]/a/b/c#joe" url->string (string->url "http://[::1]/a/b/c#joe"))
(test "http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]/a/b/c#joe"
url->string
(string->url "http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]/a/b/c#joe"))
;; test unquoting for %
(test-s->u #("http" #f "www.drscheme.org" #f #t (#("a") #("b") #("c")) ((ti#m . "")) "jo e")
"http://www.drscheme.org/a/b/c?ti%23m=#jo%20e")