fix `path-element?' collision

Is there a better name than `path-piece?'?
This commit is contained in:
Matthew Flatt 2011-08-19 19:37:31 -06:00
parent 758edda5ce
commit e61ea772bb
6 changed files with 16 additions and 17 deletions

View File

@ -1,10 +1,8 @@
#lang racket/base
(require racket/contract racket/dict racket/match)
(define path-element?
(define path-piece?
(or/c path-string? (symbols 'up 'same)))
;; Eli: We already have a notion of "path element" which is different
;; from this (see `string->path-element') .
(define port-number? (between/c 1 65535))
(define tcp-listen-port? (between/c 0 65535))
@ -406,7 +404,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide/contract
[path-element? contract?]
[path-piece? contract?]
[port-number? contract?]
[tcp-listen-port? contract?]

View File

@ -15,7 +15,7 @@
;; Eli: We already have `explode-path', this looks like it's doing the
;; same thing, except a little less useful.
; strip-prefix-ups : (listof path-element?) -> (listof path-element?)
; strip-prefix-ups : (listof path-piece?) -> (listof path-piece?)
(define (strip-prefix-ups l)
(define prefix? (box #t))
(filter (lambda (p)
@ -39,7 +39,7 @@
;; and if this wasn't enough, there's exactly one place in the web
;; server that uses it.
; path-without-base : path? path? -> (listof path-element?)
; path-without-base : path? path? -> (listof path-piece?)
(define (path-without-base base path)
(define b (explode-path* base))
(define p (explode-path* path))
@ -72,8 +72,8 @@
;; directory in the first case.
(provide/contract
[explode-path* (path-string? . -> . (listof path-element?))]
[path-without-base (path-string? path-string? . -> . (listof path-element?))]
[strip-prefix-ups ((listof path-element?) . -> . (listof path-element?))]
[explode-path* (path-string? . -> . (listof path-piece?))]
[path-without-base (path-string? path-string? . -> . (listof path-piece?))]
[strip-prefix-ups ((listof path-piece?) . -> . (listof path-piece?))]
[directory-part (path-string? . -> . path?)]
[build-path-unless-absolute (path-string? path-string? . -> . path?)])

View File

@ -35,7 +35,7 @@ Equivalent to @racket[(between/c 1 65535)].
Equivalent to @racket[(between/c 0 65535)].
}
@defthing[path-element? contract?]{
@defthing[path-piece? contract?]{
Equivalent to @racket[(or/c path-string? (symbols 'up 'same))].
}

View File

@ -14,13 +14,13 @@
@unstable-header[]
@defproc[(explode-path* [p path-string?])
(listof path-element?)]{
(listof path-piece?)]{
Like @racket[normalize-path], but does not resolve symlinks.
}
@defproc[(path-without-base [base path-string?]
[p path-string?])
(listof path-element?)]{
(listof path-piece?)]{
Returns, as a list, the portion of @racket[p] after @racket[base],
assuming @racket[base] is a prefix of @racket[p].
}
@ -37,7 +37,7 @@
Prepends @racket[base] to @racket[p], unless @racket[p] is absolute.
}
@defproc[(strip-prefix-ups [p (listof path-element?)])
(listof path-element?)]{
@defproc[(strip-prefix-ups [p (listof path-piece?)])
(listof path-piece?)]{
Removes all the prefix @racket[".."]s from @racket[p].
}

View File

@ -4,7 +4,7 @@
racket/contract)
(require web-server/private/util)
(define url->path/c
((url?) () . ->* . (values path? (listof path-element?))))
((url?) () . ->* . (values path? (listof path-piece?))))
(provide/contract
[url->path/c contract?]

View File

@ -7,7 +7,8 @@
web-server/private/servlet
racket/date
web-server/private/util
web-server/private/connection-manager)
web-server/private/connection-manager
unstable/contract)
(for-syntax racket/base))
@title[#:tag "dispatchers"
@ -78,7 +79,7 @@ This module provides a means of mapping
URLs to paths on the filesystem.
@defthing[url->path/c contract?]{
This contract is equivalent to @racket[((url?) . ->* . (path? (listof path-element?)))].
This contract is equivalent to @racket[((url?) . ->* . (path? (listof path-piece?)))].
The returned @racket[path?] is the path on disk. The list is the list of
path elements that correspond to the path of the URL.}