uri::split

 uri::split

Defined in

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
[ hide source ] | [ make this the default ]
Show another procedure: