uri::split (public)
uri::split url [ defaultscheme ]
Defined in packages/acs-tcl/tcl/tcllib-doc-procs.tcl
Split a URI into scheme-dependent component name/value pairs using Tcllib. The result is suitable for array set or dict operations. Parsing follows the package's configured URI quirk options.
- Parameters:
- url (required)
- URI to parse.
- defaultscheme (optional, defaults to
"http")- Scheme used when the URI has no scheme; defaults to http.
- Returns:
- Component names and values, including the scheme.
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set url [string trim $url] set scheme {} # RFC 3986 Sec 3.1: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) regexp -- {^([A-Za-z][A-Za-z0-9+.-]*):} $url dummy scheme if {$scheme == {}} { set scheme $defaultscheme switch -- $scheme { http - https - ftp { # x/y -> //x/y PREPEND // # /x/y -> ///x/y PREPEND // # //x/y -> //x/y # ///x/y -> ///x/y # ////x/y -> ////x/y if {[string range $url 0 1] != "//"} { set url //$url } } } } # ease maintenance: dynamic dispatch, able to handle all schemes # added in future! if {[::info procs Split[string totitle $scheme]] == {}} { error "unknown scheme '$scheme' in '$url'" } regsub -- "^${scheme}:" $url {} url # Pass url without scheme: to the per-scheme handler. set parts(scheme) [string tolower $scheme] array set parts [Split[string totitle $scheme] $url] # Does not decode encoded characters. return [array get parts]XQL Not present: Generic, PostgreSQL, Oracle