apply Andy's diff (and adjust the documentation correspondingly)
closes PR 12652
This commit is contained in:
parent
b3002cfab0
commit
fdf3fa6492
|
@ -1,5 +1,6 @@
|
||||||
#lang scribble/doc
|
#lang scribble/doc
|
||||||
@(require "common.rkt" scribble/bnf
|
@(require "common.rkt" scribble/bnf
|
||||||
|
(only-in net/url url-regexp)
|
||||||
(for-label net/url net/url-unit net/url-sig
|
(for-label net/url net/url-unit net/url-sig
|
||||||
net/head net/uri-codec net/tcp-sig
|
net/head net/uri-codec net/tcp-sig
|
||||||
(only-in net/url-connect current-https-protocol)
|
(only-in net/url-connect current-https-protocol)
|
||||||
|
@ -95,7 +96,7 @@ An HTTP connection is created as a @deftech{pure port} or a
|
||||||
have been removed, so that what remains is purely the first content
|
have been removed, so that what remains is purely the first content
|
||||||
fragment. An impure port is one that still has its MIME headers.
|
fragment. An impure port is one that still has its MIME headers.
|
||||||
|
|
||||||
@defproc[(string->url [str string?]) url?]{
|
@defproc[(string->url [str (and/c (or/c string? bytes?) url-regexp)]) url?]{
|
||||||
|
|
||||||
Parses the URL specified by @racket[str] into a @racket[url]
|
Parses the URL specified by @racket[str] into a @racket[url]
|
||||||
struct. The @racket[string->url] procedure uses
|
struct. The @racket[string->url] procedure uses
|
||||||
|
@ -122,6 +123,16 @@ parsed as an absolute path, and the parsing details depend on
|
||||||
|
|
||||||
]}
|
]}
|
||||||
|
|
||||||
|
@defthing[url-regexp regexp?]{
|
||||||
|
|
||||||
|
This is a regular expression based on the one in
|
||||||
|
Appendix B of RFC 3986 for recognizing urls.
|
||||||
|
|
||||||
|
This is the precise regexp:
|
||||||
|
|
||||||
|
@centered{@tt{@(object-name url-regexp)}}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@defproc[(combine-url/relative [base url?] [relative string?]) url?]{
|
@defproc[(combine-url/relative [base url?] [relative string?]) url?]{
|
||||||
|
|
||||||
|
|
|
@ -433,7 +433,7 @@
|
||||||
;; `*' instead of `+' for the scheme part (it is checked later anyway, and
|
;; `*' instead of `+' for the scheme part (it is checked later anyway, and
|
||||||
;; we don't want to parse it as a path element), and the user@host:port is
|
;; we don't want to parse it as a path element), and the user@host:port is
|
||||||
;; parsed here.
|
;; parsed here.
|
||||||
(define url-rx
|
(define url-regexp
|
||||||
(regexp (string-append
|
(regexp (string-append
|
||||||
"^"
|
"^"
|
||||||
"(?:" ; / scheme-colon-opt
|
"(?:" ; / scheme-colon-opt
|
||||||
|
@ -488,8 +488,7 @@
|
||||||
[query (if query (form-urlencoded->alist query) '())]
|
[query (if query (form-urlencoded->alist query) '())]
|
||||||
[fragment (uri-decode/maybe fragment)])
|
[fragment (uri-decode/maybe fragment)])
|
||||||
(make-url scheme user host port abs? path query fragment))))
|
(make-url scheme user host port abs? path query fragment))))
|
||||||
(cdr (or (regexp-match url-rx str)
|
(cdr (regexp-match url-regexp str))))
|
||||||
(url-error "Invalid URL string: ~e" str)))))
|
|
||||||
|
|
||||||
(define (uri-decode/maybe f) (friendly-decode/maybe f uri-decode))
|
(define (uri-decode/maybe f) (friendly-decode/maybe f uri-decode))
|
||||||
|
|
||||||
|
@ -661,7 +660,8 @@
|
||||||
(provide (struct-out url) (struct-out path/param))
|
(provide (struct-out url) (struct-out path/param))
|
||||||
|
|
||||||
(provide/contract
|
(provide/contract
|
||||||
(string->url ((or/c bytes? string?) . -> . url?))
|
[url-regexp regexp?]
|
||||||
|
(string->url (url-regexp . -> . url?))
|
||||||
(path->url ((or/c path-string? path-for-some-system?) . -> . url?))
|
(path->url ((or/c path-string? path-for-some-system?) . -> . url?))
|
||||||
(url->string (url? . -> . string?))
|
(url->string (url? . -> . string?))
|
||||||
(url->path (->* (url?) ((one-of/c 'unix 'windows)) path-for-some-system?))
|
(url->path (->* (url?) ((one-of/c 'unix 'windows)) path-for-some-system?))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user