Index: openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl,v diff -u -r1.65 -r1.66 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 11 Jan 2004 20:56:13 -0000 1.65 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 28 Jan 2004 17:44:53 -0000 1.66 @@ -3255,11 +3255,11 @@ } ad_proc -public util_url_valid_p { query_url } { - Returns 1 if a URL is a web URL (HTTP or HTTPS). + Returns 1 if a URL is a web URL (HTTP, HTTPS or FTP). @author Philip Greenspun (philg@mit.edu) } { - return [regexp {https?://[^ ].+} [string trim $query_url]] + return [regexp -nocase {^(http|https|ftp)://[^ ].+} [string trim $query_url]] } ad_proc -public value_if_exists { var_name } { Index: openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl,v diff -u -r1.20 -r1.21 --- openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl 12 Jan 2004 16:00:43 -0000 1.20 +++ openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl 28 Jan 2004 17:44:53 -0000 1.21 @@ -742,3 +742,29 @@ set randomized_list [util::randomize_list $org_list] aa_true "Long random list" [util_sets_equal_p $org_list $randomized_list] } + +aa_register_case acs_tcl__util_url_valid_p { + A very rudimentary test of util_url_valid_p +} { + foreach url { + "http://example.com" + "https://example.com" + "ftp://example.com" + "http://example.com/" + "HTTP://example.com" + "http://example.com/foo/bar/blah" + "http://example.com?foo=bar&bar=foo" + } { + aa_true "Valid web URL $url" [util_url_valid_p "$url"] + } + foreach url { + "xhttp://example.com" + "httpx://example.com" + "wysiwyg://example.com" + "mailto:joe@example.com" + "foo" + "/foo/bar" + } { + aa_false "Invalid web URL $url" [util_url_valid_p "$url"] + } +}