For more information including compatibility, examples and test cases, see

0.1. URIs: (import (slib uri))

A package for creating, decoding and testing various forms of URI.

0.1.1. absolute-path

absolute-path? returns true if the given filename is an absolute path, or false if it depends on the current directory.

> (absolute-path? "/usr/local/bin/scheme")
> (absolute-path? "../filename")

0.1.2. absolute-uri?

absolute-uri? returns true if the given uri is an absolute uri (containing a complete description of the named resource), or false otherwise.

> (absolute-uri? "")
> (absolute-uri? "resource.txt")

0.1.3. glob-pattern?

glob-pattern? returns true if the given string contains any symbol typically used in a glob, i.e. * ? [ ]

> (glob-pattern? "/home/dir/*/file.txt")
> (glob-pattern? "/home/dir/x/file?.txt")
> (glob-pattern? "/home/dir/x/fil[e].txt")
> (glob-pattern? "/home/dir/x/file.txt")

0.1.4. html syntax

The following four functions generate html text for different purposes:

  • html:anchor creates a named location given a name as a string.

  • html:base returns a string representing the base of given uri.

  • html:isindex creates a string for a search prompt (now deprecated for html forms).

  • html:link takes a uri and title, and returns a link to uri displaying the title.

> (html:anchor "location")    ;; <1>
<A NAME="location"></A>
> (html:base "")
> (html:isindex "Search term: ")
<ISINDEX PROMPT="Search term: ">
> (html:link "" "home page")
<A HREF="">home page</A>
  1. Use "<A HREF=#location>" to link back to this location.

0.1.5. make-uri

make-uri constructs a URI given from 0 to 5 arguments. These are: scheme, authority, path, query, fragment. These are optional from the front, so a single argument will be treated as the fragment; two arguments as a query and then a fragment, etc.

> (make-uri)                                                          ; <1>

> (make-uri "xyz")                                                    ; <2>
> (make-uri "query" "xyz")                                            ; <3>
> (make-uri "http" "" "/files/location" "query" "xyz")  ; <4>
  1. Returns the empty string

  2. Single argument is a Fragment

  3. Query and Fragment

  4. All components: the authority in this case is the web address, and the path the relative location of files

0.1.6. null-directory?

null-directory? takes a string and returns true if the string names the current directory (so changing to it would not make any change).

0.1.7. parse-ftp-address

parse-ftp-address converts a string, representing an ftp address, into a list of up to four values: the username, password, remote site, and remote directory. #f is returned if any of these values is not present, or #f instead of a list if the string is not an ftp address.

> (parse-ftp-address "")
("username" #f "" #f)
> (parse-ftp-address "")
("username" "password" "" "dir")

0.1.8. path→uri

path→uri converts a given path (as a string) into a URI with an absolute address.

> (path->uri "filename.txt")
> (path->uri "/usr/local/filename.txt")

0.1.9. uri→tree

uri→tree takes a URI and returns a list of five values corresponding to the scheme, authority, path, query, fragment:

> (uri->tree "file:/usr/local/filename.txt")
(file #f ("" "usr" "local" "filename.txt") #f #f)

0.1.10. uri:decode-query

uri:decode-query converts a given query string into an association list of key-value pairs:

> (uri:decode-query "name=XXX&date=32")
((date "32") (name "XXX"))

0.1.11. uri:make-path

uri:make-path takes a list of strings, and returns a path component by joining the strings together with a suitable separator:

> (uri:make-path '("a" "b" "c"))

0.1.12. uri:splitfields

uri:splitfields splits a string at a given character.

> (uri:splitfields "some text to split" #\space)
'("some" "text" "to" "split")

0.1.13. uric:decode/encode

uric:decode and uric:encode convert a string to and from a form with certain characters rewritten using % octal values:

> (uric:decode "xxx%20yyy")
"xxx yyy"
> (uric:encode "xxx yyy")

An optional second argument to uric:encode provides a string of characters to allow.