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.140.2.56 -r1.140.2.57 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 6 Jan 2017 11:48:05 -0000 1.140.2.56 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 13 Jan 2017 14:16:20 -0000 1.140.2.57 @@ -4982,65 +4982,9 @@ return $result } + } - package require tcltest 2.2 - namespace import -force ::tcltest::* - ::tcltest::configure {*}$argv - - test ns_parseurl-1.0 {basic syntax: plain call} -body { - ns_parseurl - } -returnCodes error -result {wrong # args: should be "ns_parseurl url"} - - test ns_parseurl-1.1 {full url, no port} -body { - ns_parseurl http://openacs.org/www/t.html - } -result {proto http host openacs.org path www tail t.html} - - test ns_parseurl-1.2 {full url, no port} -body { - ns_parseurl http://openacs.org:80/www/t.html - } -result {proto http host openacs.org port 80 path www tail t.html} - - test ns_parseurl-1.3 {full url, no port, no component} -body { - ns_parseurl http://openacs.org/ - } -result {proto http host openacs.org path {} tail {}} - - test ns_parseurl-1.4 {full url, no port, no component, no trailing slash} -body { - ns_parseurl http://openacs.org - } -result {proto http host openacs.org path {} tail {}} - - test ns_parseurl-1.5 {full url, no port, one component} -body { - ns_parseurl http://openacs.org/t.html - } -result {proto http host openacs.org path {} tail t.html} - - # - # relative URLs - # - - test ns_parseurl-2.1 {relative url} -body { - ns_parseurl /www/t.html - } -result {path www tail t.html} - - # legacy NaviServer, desired? - test ns_parseurl-2.2 {relative url, no leading /} -body { - ns_parseurl www/t.html - } -result {tail www/t.html} - - # - # protocol relative (protocol agnostic) URLs (contained in RFC 3986) - # - test ns_parseurl-3.1 {protocol relative url with port} -body { - ns_parseurl //openacs.org/www/t.html - } -result {host openacs.org path www tail t.html} - - test ns_parseurl-3.2 {protocol relative url without port} -body { - ns_parseurl //openacs.org:80/www/t.html - } -result {host openacs.org port 80 path www tail t.html} - - - cleanupTests -} - - # Local variables: # mode: tcl # tcl-indent-level: 4 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.41.2.3 -r1.41.2.4 --- openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl 10 Sep 2015 08:22:02 -0000 1.41.2.3 +++ openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl 13 Jan 2017 14:16:20 -0000 1.41.2.4 @@ -1133,6 +1133,56 @@ } +aa_register_case -cats {api smoke} util__ns_parseurl { + Test ns_parseurl + + @author Gustaf Neumann +} { + aa_equals "full url, no port" \ + [ns_parseurl http://openacs.org/www/t.html] \ + {proto http host openacs.org path www tail t.html} + + aa_equals "full url, with port" \ + [ns_parseurl http://openacs.org:80/www/t.html] \ + {proto http host openacs.org port 80 path www tail t.html} + + aa_equals "full url, no port, no component" \ + [ns_parseurl http://openacs.org/] \ + {proto http host openacs.org path {} tail {}} + + aa_equals "full url, no port, no component, no trailing slash" \ + [ns_parseurl http://openacs.org] \ + {proto http host openacs.org path {} tail {}} + + aa_equals "full url, no port, one component" \ + [ns_parseurl http://openacs.org/t.html] \ + {proto http host openacs.org path {} tail t.html} + + # + # relative URLs + # + aa_equals "relative url" \ + [ns_parseurl /www/t.html] \ + {path www tail t.html} + + # legacy NaviServer for pre HTTP/1.0, desired? + + aa_equals "legacy NaviServer, pre HTTP/1.0, no leading /" \ + [ns_parseurl www/t.html] \ + {tail www/t.html} + + # + # protocol relative (protocol agnostic) URLs (contained in RFC 3986) + # + aa_equals "protocol relative url with port" \ + [ns_parseurl //openacs.org/www/t.html] \ + {host openacs.org path www tail t.html} + + aa_equals "protocol relative url without port" \ + [ns_parseurl //openacs.org:80/www/t.html] \ + {host openacs.org port 80 path www tail t.html} +} + # Local variables: # mode: tcl # tcl-indent-level: 4