ug_parse_url

one of the documented procedures in this installation of the ACS
Usage:
ug_parse_url   url_string
What it does:
this procedure takes url in the form /A/B/C and returns tcl list whose members are A, B and C. if the last element of this tcl list is /, then this / will be added as the last element in the list (e.g. /A/B/C/ will have elements A, B, C and /). if url_string is empty, procedure will return an empty list
Defined in: /web/philip/tcl/user-group-defs.tcl

Source code:


    set url_list [list]

    set url_string_length [string length $url_string]    
    if { $url_string_length == 0 } {
	return $url_list
    }

    set last_url_char [string range $url_string [expr $url_string_length - 1] [expr $url_string_length - 1]]

    if { [string compare $last_url_char /]==0 } {
	set include_final_slash_p 1
	set url_without_initial_and_final_slash [string range $url_string 1 [expr $url_string_length - 2]]
    } else {
	set include_final_slash_p 0
	set url_without_initial_and_final_slash [string range $url_string 1 [expr $url_string_length - 1]]
    }
    
    set url_list [split $url_without_initial_and_final_slash /]
    if { $include_final_slash_p } {
	lappend url_list /
    }

    return $url_list


philg@mit.edu