Updated 2014-05-21 10:32:31 by RLE

uri is a Tcllib module for parsing and manipulating URIs.

Documentation  edit

official reference
official reference, development version

Description  edit

uri::split breaks a URI up into its component parts.

The parts identified depend on the schemes supported. For instance, for ftp, the pieces identified are

  • host
  • path
  • port
  • passwd
  • scheme
  • type
  • user

The file protocol is supported

The data protocol is not yet supported.

LV: What does "doesn't yet support" mean?

AK: That the code does not know to handle such urls (split/join). There are no regexp patterns either.

LV: but I see this behavior with tcl8.4 and tcllib 1.0:
% package require uri
% set name "file://home/lwv26/myfile.txt"
% uri::split $name
path /lwv26/myfile.txt scheme file host home

So it LOOKS like file is supported.

VFS handlers  edit

The new Tcl 8.4a4 VFS layer by Vince Darley simplifies this work. See the "tclvfs" extension on SourceForge [1] for example code which opens http, ftp, zip, and more - using the "blah:..." notation.

Issue: Canonicalize  edit

HaO 2013-05-03 I tried to use 'uri::canonicalize' to implement a smart url completer, e.g. to say transform "test.de" to "http://test.de/".
% package require uri
% uri::canonicalize test.de

So there are 3 slashes instead of two and no trailing slash. This is not what I intended.

The reason is, that 'uri::canonicalize' internally uses 'uri::split' and 'uri::join'' and the first interpretes the given data as a path and not as a host:
% ::uri::split test.de
fragment {} port {} path test.de scheme http host {} query {}

Changelog  edit

AK: The urn handler was added to tcllib after the 1.1.0 release