The port is automatically determined if it is omitted and the URI scheme is known.

Library Procedures

This library replaces most of the procedures in uri-generic. If you need to work with URIs on the uri-generic level or need to work with both uri-generic and uri-common URI objects, you will have to import and prefix or rename procedures.

Constructors

These constructors fully decode their arguments, so afterwards it is impossible to distinguish between encoded delimiters and unencoded delimiters. This makes uri-common objects decoding endpoints; no further decoding on the URI level is possible (of course, applications are free to decode further information inside the URI). If for some reason, the original URI is still needed, it can be converted to a uri-generic. However, updating a URI component causes this component's original encoding to be lost, so be careful!

[procedure](uri-reference string) => uri-common

A URI reference is either a URI or a relative reference (RFC 3986, Section 4.1). If the given string's prefix does not match the syntax of a scheme followed by a colon separator, then the given string is parsed as a relative reference.

[procedure](absolute-uri string) => uri-common

Parses the given string as an absolute URI, in which no fragments are allowed (RFC 3986, Section 4.2)

uri-generic and string representation

To convert between uri-generic and uri-common objects, use these procedures. As stated above, this will allow you to retrieve the original encoding of the URI components, but once you update a component from the uri-common side, the original encoding is no longer available (the updated value replaces the original value).

[procedure](uri->string uri-common userinfo) => string

Reconstructs the given URI into a string; uses a supplied function LAMBDA USERNAME PASSWORD -> STRING to map the userinfo part of the URI.

Predicates and Accessors

<procedure>(uri? uri-common) => bool</procedure>

<procedure>(uri-scheme uri-common) => symbol</procedure>

<procedure>(uri-path uri-common) => list</procedure>

<procedure>(uri-query uri-common) => alist</procedure>

<procedure>(uri-fragment uri-common) => string</procedure>

<procedure>(uri-host uri-common) => string</procedure>

<procedure>(uri-port uri-common) => integer</procedure>

<procedure>(uri-username uri-common) => string</procedure>

<procedure>(uri-password uri-common) => string</procedure>

If a component is not defined in the given URI-common, then the corresponding accessor returns #f.

Encode or decode an alist using the encoding corresponding to the form-urlencoded media type, using the given separator character(s).

When encoding, if separator is a string, the first character will be used as the separator in the resulting querystring. If it is a char-set, it will be converted to a string and its first character will be taken. In either case, all of these characters are encoded if they occur inside the key/value pairs.

When decoding, any character in the set (or string) will be seen as a separator.

The separator defaults to the string ";&". This means that either semicolons or ampersands are allowed as separators when decoding an URI string, but semicolons are used when generating strings.

If you would like to use a different separator, you should parameterize all calls to procedures that return an uri-common object.

Normalization

[procedure](uri-normalize-case URI) => URI

URI case normalization (RFC 3986 section 6.2.2.1)

[procedure](uri-normalize-path-segments URI) => URI

URI path segment normalization (RFC 3986 section 6.2.2.3)

Requires

Version History

0.1 Initial Release

License

Copyright 2008-2009 Peter Bex
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of the author nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.