{"size": 2130, "ext": "scrbl", "max_stars_repo_path": "web-server-doc/web-server/scribblings/misc-util.scrbl", "max_stars_repo_name": "jessealama/web-server", "max_stars_repo_stars_event_min_datetime": "2015-01-21T08:11:58.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T08:28:39.000Z", "max_issues_repo_path": "web-server-doc/web-server/scribblings/misc-util.scrbl", "max_issues_repo_name": "jessealama/web-server", "max_issues_repo_issues_event_min_datetime": "2015-01-14T08:06:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-12T14:38:40.000Z", "max_forks_repo_path": "web-server-doc/web-server/scribblings/misc-util.scrbl", "max_forks_repo_name": "jessealama/web-server", "max_forks_repo_forks_event_min_datetime": "2015-03-05T15:07:36.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-30T18:59:25.000Z"}
{"max_stars_count": 82, "max_issues_count": 105, "max_forks_count": 37, "avg_line_length": 28.7837837838, "max_line_length": 84, "alphanum_fraction": 0.6154929577}
#lang scribble/doc
@(require "web-server.rkt")

@title[#:tag "misc-util" #:style 'toc]{Miscellaneous Utilities}

@(require (for-label web-server/private/util
                     racket/path))

@defmodule[web-server/private/util]

@defproc[(bytes-ci=? [b1 bytes?] [b2 bytes?]) boolean?]{
 Compares two bytes case insensitively.
}

@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.
}

@defproc[(explode-path* [p path-string?])
         (listof path-piece?)]{
 Like @racket[normalize-path], but does not resolve symlinks.
}

@defproc[(path-without-base [base path-string?]
                            [p path-string?])
         (listof path-piece?)]{
 Returns, as a list, the portion of @racket[p] after @racket[base],
 assuming @racket[base] is a prefix of @racket[p].
}

@defproc[(directory-part [p path-string?])
         path?]{
 Returns the directory part of @racket[p], returning @racket[(current-directory)]
 if it is relative.
}

@defproc[(build-path-unless-absolute [base path-string?]
                                     [p path-string?])
         path?]{
 Prepends @racket[base] to @racket[p], unless @racket[p] is absolute.
}

@defproc[(network-error [s symbol?]
                        [fmt string?]
                        [v any/c] ...)
         void]{
 Like @racket[error], but throws a @racket[exn:fail:network].
}

@defproc[(exn->string [exn (or/c exn? any/c)])
         string?]{
 Formats @racket[exn] with @racket[(error-display-handler)] as a string.
}

@defproc[(read/bytes [bstr bytes?]) printable/c]{
 Extracts a value from @racket[bstr] using @racket[read].
}

@defproc[(write/bytes [v printable/c]) bytes?]{
 Prints @racket[v] into a byte string using @racket[write].
}

@defthing[path-piece? contract?]{
Equivalent to @racket[(or/c path-string? (symbols 'up 'same))].
}
