removed unstable/net/url (moved code back to web-server)
This commit is contained in:
parent
7f345fe067
commit
dd061bdb17
|
@ -1,57 +0,0 @@
|
|||
#lang racket/base
|
||||
(require racket/list
|
||||
racket/contract/base
|
||||
net/url-structs)
|
||||
|
||||
(provide/contract
|
||||
[url-replace-path (((listof path/param?) . -> . (listof path/param?)) url? . -> . url?)]
|
||||
[url-path->string ((listof path/param?) . -> . string?)])
|
||||
|
||||
;; replace-path: (url-path -> url-path) url -> url
|
||||
;; make a new url by replacing the path part of a url with a function
|
||||
;; of the url's old path
|
||||
;; also remove the query
|
||||
(define (url-replace-path proc in-url)
|
||||
(let ([new-path (proc (url-path in-url))])
|
||||
(make-url
|
||||
(url-scheme in-url)
|
||||
(url-user in-url)
|
||||
(url-host in-url)
|
||||
(url-port in-url)
|
||||
(url-path-absolute? in-url)
|
||||
new-path
|
||||
empty
|
||||
(url-fragment in-url))))
|
||||
;; Eli: if it also removes the query, this it's a bad name, and it's
|
||||
;; questionable whether it is general enough. Why not make it into a
|
||||
;; keyworded function that can change any part, which sounds like a much more
|
||||
;; useful utility? Some `foo' that would allow:
|
||||
;; (define (url-replace-path proc in-url)
|
||||
;; (foo in-url #:path (proc (url-path in-url)) #:query '()))
|
||||
;; or even accept a changing function for all keywords:
|
||||
;; (define (url-replace-path proc in-url)
|
||||
;; (foo in-url #:path proc #:query '()))
|
||||
|
||||
;; ripped this off from url-unit.rkt
|
||||
(define (url-path->string strs)
|
||||
(apply string-append
|
||||
(apply append
|
||||
(map (lambda (s) (list "/" (maybe-join-params s)))
|
||||
strs))))
|
||||
|
||||
;; needs to unquote things!
|
||||
(define (maybe-join-params s)
|
||||
(if (string? s)
|
||||
s
|
||||
(let ([s (path/param-path s)])
|
||||
(if (string? s)
|
||||
s
|
||||
(case s
|
||||
[(same) "."]
|
||||
[(up) ".."]
|
||||
[else (error 'maybe-join-params
|
||||
"bad value from path/param-path: ~e" s)])))))
|
||||
;; Eli: I don't know what this is supposed to be doing -- I don't see any
|
||||
;; "maybe"ness), it throws away the `path/param-param's, and it accepts
|
||||
;; strings too (which makes me wonder how is this related to the url
|
||||
;; library).
|
|
@ -1,14 +0,0 @@
|
|||
#lang scribble/doc
|
||||
@(require scribble/base
|
||||
scribble/manual
|
||||
"utils.rkt")
|
||||
|
||||
@title[#:tag "net" #:style 'toc]{Net}
|
||||
|
||||
@defmodule[unstable/net]
|
||||
|
||||
@unstable-header[]
|
||||
|
||||
@local-table-of-contents[]
|
||||
|
||||
@include-section["net/url.scrbl"]
|
|
@ -1,26 +0,0 @@
|
|||
#lang scribble/doc
|
||||
@(require scribble/base
|
||||
scribble/manual
|
||||
"../utils.rkt"
|
||||
(for-label unstable/net/url
|
||||
net/url
|
||||
racket/contract
|
||||
racket/base))
|
||||
|
||||
@title[#:tag "url"]{URLs}
|
||||
|
||||
@defmodule[unstable/net/url]
|
||||
|
||||
@unstable-header[]
|
||||
|
||||
@defproc[(url-replace-path [proc ((listof path/param?) . -> . (listof path/param?))]
|
||||
[u url?])
|
||||
url?]{
|
||||
Replaces the URL path of @racket[u] with @racket[proc] of the former path.
|
||||
}
|
||||
|
||||
@defproc[(url-path->string [url-path (listof path/param?)])
|
||||
string?]{
|
||||
Formats @racket[url-path] as a string with @racket["/"] as a delimiter
|
||||
and no params.
|
||||
}
|
|
@ -92,7 +92,6 @@ Keep documentation and tests up to date.
|
|||
@include-section["markparam.scrbl"]
|
||||
@include-section["parameter-group.scrbl"]
|
||||
@include-section["match.scrbl"]
|
||||
@include-section["net.scrbl"]
|
||||
@include-section["port.scrbl"]
|
||||
@include-section["pretty.scrbl"]
|
||||
@include-section["sequence.scrbl"]
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
#lang racket/base
|
||||
(require racket/contract/base
|
||||
racket/list
|
||||
unstable/list
|
||||
unstable/contract
|
||||
racket/serialize)
|
||||
racket/serialize
|
||||
net/url-structs)
|
||||
(require unstable/bytes
|
||||
unstable/contract
|
||||
unstable/list
|
||||
unstable/net/url)
|
||||
unstable/list)
|
||||
(provide
|
||||
(all-from-out
|
||||
unstable/bytes
|
||||
unstable/contract
|
||||
unstable/list
|
||||
unstable/net/url))
|
||||
unstable/list))
|
||||
|
||||
;; --
|
||||
|
||||
|
@ -144,3 +144,58 @@
|
|||
[lowercase-symbol! ((or/c string? bytes?) . -> . symbol?)]
|
||||
[read/string (string? . -> . serializable?)]
|
||||
[write/string (serializable? . -> . string?)])
|
||||
|
||||
;; --
|
||||
|
||||
(provide/contract
|
||||
[url-replace-path (((listof path/param?) . -> . (listof path/param?)) url? . -> . url?)]
|
||||
[url-path->string ((listof path/param?) . -> . string?)])
|
||||
|
||||
;; replace-path: (url-path -> url-path) url -> url
|
||||
;; make a new url by replacing the path part of a url with a function
|
||||
;; of the url's old path
|
||||
;; also remove the query
|
||||
(define (url-replace-path proc in-url)
|
||||
(let ([new-path (proc (url-path in-url))])
|
||||
(make-url
|
||||
(url-scheme in-url)
|
||||
(url-user in-url)
|
||||
(url-host in-url)
|
||||
(url-port in-url)
|
||||
(url-path-absolute? in-url)
|
||||
new-path
|
||||
empty
|
||||
(url-fragment in-url))))
|
||||
;; Eli: if it also removes the query, this it's a bad name, and it's
|
||||
;; questionable whether it is general enough. Why not make it into a
|
||||
;; keyworded function that can change any part, which sounds like a much more
|
||||
;; useful utility? Some `foo' that would allow:
|
||||
;; (define (url-replace-path proc in-url)
|
||||
;; (foo in-url #:path (proc (url-path in-url)) #:query '()))
|
||||
;; or even accept a changing function for all keywords:
|
||||
;; (define (url-replace-path proc in-url)
|
||||
;; (foo in-url #:path proc #:query '()))
|
||||
|
||||
;; ripped this off from url-unit.rkt
|
||||
(define (url-path->string strs)
|
||||
(apply string-append
|
||||
(apply append
|
||||
(map (lambda (s) (list "/" (maybe-join-params s)))
|
||||
strs))))
|
||||
|
||||
;; needs to unquote things!
|
||||
(define (maybe-join-params s)
|
||||
(if (string? s)
|
||||
s
|
||||
(let ([s (path/param-path s)])
|
||||
(if (string? s)
|
||||
s
|
||||
(case s
|
||||
[(same) "."]
|
||||
[(up) ".."]
|
||||
[else (error 'maybe-join-params
|
||||
"bad value from path/param-path: ~e" s)])))))
|
||||
;; Eli: I don't know what this is supposed to be doing -- I don't see any
|
||||
;; "maybe"ness), it throws away the `path/param-param's, and it accepts
|
||||
;; strings too (which makes me wonder how is this related to the url
|
||||
;; library).
|
||||
|
|
Loading…
Reference in New Issue
Block a user