diff --git a/collects/unstable/net/url.rkt b/collects/unstable/net/url.rkt deleted file mode 100644 index 03344fc689..0000000000 --- a/collects/unstable/net/url.rkt +++ /dev/null @@ -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). diff --git a/collects/unstable/scribblings/net.scrbl b/collects/unstable/scribblings/net.scrbl deleted file mode 100644 index d0c1b8c934..0000000000 --- a/collects/unstable/scribblings/net.scrbl +++ /dev/null @@ -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"] diff --git a/collects/unstable/scribblings/net/url.scrbl b/collects/unstable/scribblings/net/url.scrbl deleted file mode 100644 index e77550ae64..0000000000 --- a/collects/unstable/scribblings/net/url.scrbl +++ /dev/null @@ -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. -} diff --git a/collects/unstable/scribblings/unstable.scrbl b/collects/unstable/scribblings/unstable.scrbl index aa35c08354..d0a0d49ebc 100644 --- a/collects/unstable/scribblings/unstable.scrbl +++ b/collects/unstable/scribblings/unstable.scrbl @@ -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"] diff --git a/collects/web-server/private/util.rkt b/collects/web-server/private/util.rkt index e733f2b4f2..6e8ac6b199 100644 --- a/collects/web-server/private/util.rkt +++ b/collects/web-server/private/util.rkt @@ -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).