path-element

svn: r6641
This commit is contained in:
Jay McCarthy 2007-06-13 21:01:27 +00:00
parent 8e6cb291ea
commit d962bfa25e
3 changed files with 16 additions and 13 deletions

View File

@ -282,6 +282,7 @@ needs. They are provided by @file{private/util.ss}.
@subsection{Contracts} @subsection{Contracts}
@defthing[port-number? contract?]{Equivalent to @scheme[(between/c 1 65535)].} @defthing[port-number? contract?]{Equivalent to @scheme[(between/c 1 65535)].}
@defthing[path-element? contract?]{Equivalent to @scheme[(or/c path? (symbols 'up 'same))].}
@subsection{Lists} @subsection{Lists}
@defproc[(list-prefix? [l list?] @defproc[(list-prefix? [l list?]
@ -292,14 +293,14 @@ needs. They are provided by @file{private/util.ss}.
@subsection{URLs} @subsection{URLs}
@defproc[(url-replace-path [proc (list? . -> . list?)] @defproc[(url-replace-path [proc ((listof path/param?) . -> . (listof path/param?))]
[u url?]) [u url?])
url?]{ url?]{
Replaces the URL path of @scheme[u] with @scheme[proc] of the former path. Replaces the URL path of @scheme[u] with @scheme[proc] of the former path.
} }
@; XXX Remove use or take url? @; XXX Remove use or take url?
@defproc[(url-path->string [url-path (listof (or/c string? path/param?))]) @defproc[(url-path->string [url-path (listof path/param?)])
string?]{ string?]{
Formats @scheme[url-path] as a string with @scheme["/"] as a delimiter Formats @scheme[url-path] as a string with @scheme["/"] as a delimiter
and no params. and no params.

View File

@ -7,19 +7,21 @@
(lib "pretty.ss") (lib "pretty.ss")
(lib "xml.ss" "xml") (lib "xml.ss" "xml")
(lib "url.ss" "net")) (lib "url.ss" "net"))
(define path-element?
(or/c path? (symbols 'up 'same)))
(define port-number? (between/c 1 65535))
(provide/contract (provide/contract
[path-element? contract?]
[port-number? contract?] [port-number? contract?]
[pretty-print-invalid-xexpr (exn:invalid-xexpr? any/c . -> . void)] [pretty-print-invalid-xexpr (exn:invalid-xexpr? any/c . -> . void)]
[url-replace-path ((list? . -> . list?) url? . -> . url?)] [url-replace-path (((listof path/param?) . -> . (listof path/param?)) url? . -> . url?)]
; XXX need path-element? [explode-path* (path? . -> . (listof path-element?))]
[explode-path* (path? . -> . (listof (or/c symbol? path?)))] [path-without-base (path? path? . -> . (listof path-element?))]
; XXX need path-element?
[path-without-base (path? path? . -> . list?)]
; XXX need path-element?
[list-prefix? (list? list? . -> . boolean?)] [list-prefix? (list? list? . -> . boolean?)]
; XXX need path-element? [strip-prefix-ups ((listof path-element?) . -> . (listof path-element?))]
[strip-prefix-ups (list? . -> . list?)] [url-path->string ((listof path/param?) . -> . string?)]
[url-path->string ((listof (or/c string? path/param?)) . -> . string?)]
[network-error ((symbol? string?) (listof any/c) . ->* . (void))] [network-error ((symbol? string?) (listof any/c) . ->* . (void))]
[directory-part (path? . -> . path?)] [directory-part (path? . -> . path?)]
; XXX Eliminate use of this ; XXX Eliminate use of this
@ -29,8 +31,6 @@
[read/string (string? . -> . serializable?)] [read/string (string? . -> . serializable?)]
[write/string (serializable? . -> . string?)]) [write/string (serializable? . -> . string?)])
(define port-number? (between/c 1 65535))
(define (pretty-print-invalid-xexpr exn xexpr) (define (pretty-print-invalid-xexpr exn xexpr)
(define code (exn:invalid-xexpr-code exn)) (define code (exn:invalid-xexpr-code exn))
(parameterize ([pretty-print-size-hook (lambda (v display? out) (parameterize ([pretty-print-size-hook (lambda (v display? out)

View File

@ -10,6 +10,8 @@
(test-suite (test-suite
"Utilities" "Utilities"
; XXX path-element?
(test-suite (test-suite
"port-number?" "port-number?"
(test-not-exn "80" (lambda () (contract port-number? 80 'pos 'neg))) (test-not-exn "80" (lambda () (contract port-number? 80 'pos 'neg)))