| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  | IN: urls.tests | 
					
						
							| 
									
										
										
										
											2009-04-05 21:44:12 -04:00
										 |  |  | USING: urls urls.private tools.test prettyprint | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  | arrays kernel assocs present accessors ;
 | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 01:34:02 -04:00
										 |  |  | CONSTANT: urls | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  |     { | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |             T{ url | 
					
						
							|  |  |  |                 { protocol "http" } | 
					
						
							|  |  |  |                 { host "www.apple.com" } | 
					
						
							|  |  |  |                 { port 1234 } | 
					
						
							|  |  |  |                 { path "/a/path" } | 
					
						
							|  |  |  |                 { query H{ { "a" "b" } } } | 
					
						
							|  |  |  |                 { anchor "foo" } | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  |             } | 
					
						
							|  |  |  |             "http://www.apple.com:1234/a/path?a=b#foo" | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |             T{ url | 
					
						
							|  |  |  |                 { protocol "http" } | 
					
						
							|  |  |  |                 { host "www.apple.com" } | 
					
						
							|  |  |  |                 { path "/a/path" } | 
					
						
							|  |  |  |                 { query H{ { "a" "b" } } } | 
					
						
							|  |  |  |                 { anchor "foo" } | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  |             } | 
					
						
							|  |  |  |             "http://www.apple.com/a/path?a=b#foo" | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |             T{ url | 
					
						
							|  |  |  |                 { protocol "http" } | 
					
						
							|  |  |  |                 { host "www.apple.com" } | 
					
						
							|  |  |  |                 { port 1234 } | 
					
						
							|  |  |  |                 { path "/another/fine/path" } | 
					
						
							|  |  |  |                 { anchor "foo" } | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  |             } | 
					
						
							|  |  |  |             "http://www.apple.com:1234/another/fine/path#foo" | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |             T{ url | 
					
						
							|  |  |  |                 { path "/a/relative/path" } | 
					
						
							|  |  |  |                 { anchor "foo" } | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  |             } | 
					
						
							|  |  |  |             "/a/relative/path#foo" | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |             T{ url | 
					
						
							|  |  |  |                 { path "/a/relative/path" } | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  |             } | 
					
						
							|  |  |  |             "/a/relative/path" | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |             T{ url | 
					
						
							|  |  |  |                 { path "a/relative/path" } | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  |             } | 
					
						
							|  |  |  |             "a/relative/path" | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2008-06-01 18:22:39 -04:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |             T{ url | 
					
						
							|  |  |  |                 { path "bar" } | 
					
						
							|  |  |  |                 { query H{ { "a" "b" } } } | 
					
						
							| 
									
										
										
										
											2008-06-01 18:22:39 -04:00
										 |  |  |             } | 
					
						
							|  |  |  |             "bar?a=b" | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2008-06-02 14:27:00 -04:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |             T{ url | 
					
						
							|  |  |  |                 { protocol "ftp" } | 
					
						
							|  |  |  |                 { host "ftp.kernel.org" } | 
					
						
							|  |  |  |                 { username "slava" } | 
					
						
							|  |  |  |                 { path "/" } | 
					
						
							| 
									
										
										
										
											2008-06-02 14:27:00 -04:00
										 |  |  |             } | 
					
						
							|  |  |  |             "ftp://slava@ftp.kernel.org/" | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |             T{ url | 
					
						
							|  |  |  |                 { protocol "ftp" } | 
					
						
							|  |  |  |                 { host "ftp.kernel.org" } | 
					
						
							|  |  |  |                 { username "slava" } | 
					
						
							|  |  |  |                 { password "secret" } | 
					
						
							|  |  |  |                 { path "/" } | 
					
						
							| 
									
										
										
										
											2008-06-02 14:27:00 -04:00
										 |  |  |             } | 
					
						
							|  |  |  |             "ftp://slava:secret@ftp.kernel.org/" | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-04-10 05:01:59 -04:00
										 |  |  |         { | 
					
						
							|  |  |  |             T{ url | 
					
						
							|  |  |  |                { protocol "http" } | 
					
						
							|  |  |  |                { host "foo.com" } | 
					
						
							|  |  |  |                { path "/" } | 
					
						
							|  |  |  |                { query H{ { "a" f } } } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             "http://foo.com/?a" | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-03-23 01:34:02 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | urls [ | 
					
						
							| 
									
										
										
										
											2008-06-01 18:22:39 -04:00
										 |  |  |     [ 1array ] [ [ >url ] curry ] bi* unit-test | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  | ] assoc-each
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | urls [ | 
					
						
							| 
									
										
										
										
											2008-06-05 01:18:36 -04:00
										 |  |  |     swap [ 1array ] [ [ present ] curry ] bi* unit-test | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  | ] assoc-each
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-01 01:59:06 -04:00
										 |  |  | [ "b" ] [ "a" "b" url-append-path ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "a/b" ] [ "a/c" "b" url-append-path ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "a/b" ] [ "a/" "b" url-append-path ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "/b" ] [ "a" "/b" url-append-path ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "/b" ] [ "a/b/" "/b" url-append-path ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "/xxx/bar" ] [ "/xxx/baz" "bar" url-append-path ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  | [ | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |     T{ url | 
					
						
							|  |  |  |         { protocol "http" } | 
					
						
							|  |  |  |         { host "www.apple.com" } | 
					
						
							|  |  |  |         { port 1234 } | 
					
						
							|  |  |  |         { path "/a/path" } | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | ] [ | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |     T{ url | 
					
						
							|  |  |  |         { protocol "http" } | 
					
						
							|  |  |  |         { host "www.apple.com" } | 
					
						
							|  |  |  |         { port 1234 } | 
					
						
							|  |  |  |         { path "/foo" } | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |     T{ url | 
					
						
							|  |  |  |         { path "/a/path" } | 
					
						
							| 
									
										
										
										
											2008-06-01 01:59:06 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  |     derive-url | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |     T{ url | 
					
						
							|  |  |  |         { protocol "http" } | 
					
						
							|  |  |  |         { host "www.apple.com" } | 
					
						
							|  |  |  |         { port 1234 } | 
					
						
							|  |  |  |         { path "/a/path/relative/path" } | 
					
						
							|  |  |  |         { query H{ { "a" "b" } } } | 
					
						
							|  |  |  |         { anchor "foo" } | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | ] [ | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |     T{ url | 
					
						
							|  |  |  |         { protocol "http" } | 
					
						
							|  |  |  |         { host "www.apple.com" } | 
					
						
							|  |  |  |         { port 1234 } | 
					
						
							|  |  |  |         { path "/a/path/" } | 
					
						
							| 
									
										
										
										
											2008-06-01 01:59:06 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |     T{ url | 
					
						
							|  |  |  |         { path "relative/path" } | 
					
						
							|  |  |  |         { query H{ { "a" "b" } } } | 
					
						
							|  |  |  |         { anchor "foo" } | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     derive-url | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |     T{ url | 
					
						
							|  |  |  |         { protocol "http" } | 
					
						
							|  |  |  |         { host "www.apple.com" } | 
					
						
							|  |  |  |         { port 1234 } | 
					
						
							|  |  |  |         { path "/a/path/relative/path" } | 
					
						
							|  |  |  |         { query H{ { "a" "b" } } } | 
					
						
							|  |  |  |         { anchor "foo" } | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | ] [ | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |     T{ url | 
					
						
							|  |  |  |         { protocol "http" } | 
					
						
							|  |  |  |         { host "www.apple.com" } | 
					
						
							|  |  |  |         { port 1234 } | 
					
						
							|  |  |  |         { path "/a/path/" } | 
					
						
							| 
									
										
										
										
											2008-06-01 01:59:06 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |     T{ url | 
					
						
							|  |  |  |         { path "relative/path" } | 
					
						
							|  |  |  |         { query H{ { "a" "b" } } } | 
					
						
							|  |  |  |         { anchor "foo" } | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-01 01:59:06 -04:00
										 |  |  |     derive-url | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |     T{ url | 
					
						
							|  |  |  |         { protocol "http" } | 
					
						
							|  |  |  |         { host "www.apple.com" } | 
					
						
							|  |  |  |         { path "/xxx/baz" } | 
					
						
							| 
									
										
										
										
											2008-06-01 01:59:06 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | ] [ | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |     T{ url | 
					
						
							|  |  |  |         { protocol "http" } | 
					
						
							|  |  |  |         { host "www.apple.com" } | 
					
						
							|  |  |  |         { path "/xxx/bar" } | 
					
						
							| 
									
										
										
										
											2008-06-01 01:59:06 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-05 21:39:45 -04:00
										 |  |  |     T{ url | 
					
						
							|  |  |  |         { path "baz" } | 
					
						
							| 
									
										
										
										
											2008-06-01 00:20:24 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     derive-url | 
					
						
							|  |  |  | ] unit-test | 
					
						
							| 
									
										
										
										
											2008-06-01 18:22:39 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-29 22:50:13 -05:00
										 |  |  | [ | 
					
						
							|  |  |  |     T{ url | 
					
						
							|  |  |  |         { protocol "https" } | 
					
						
							|  |  |  |         { host "www.apple.com" } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | ] [ | 
					
						
							|  |  |  |     T{ url | 
					
						
							|  |  |  |         { protocol "http" } | 
					
						
							|  |  |  |         { host "www.apple.com" } | 
					
						
							|  |  |  |         { port 80 } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     T{ url | 
					
						
							|  |  |  |         { protocol "https" } | 
					
						
							|  |  |  |         { host "www.apple.com" } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     derive-url | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-01 18:22:39 -04:00
										 |  |  | [ "a" ] [ | 
					
						
							|  |  |  |     <url> "a" "b" set-query-param "b" query-param | 
					
						
							|  |  |  | ] unit-test | 
					
						
							| 
									
										
										
										
											2008-06-06 19:18:05 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ "foo#3" ] [ URL" foo" clone 3 >>anchor present ] unit-test | 
					
						
							| 
									
										
										
										
											2008-09-23 15:17:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ "http://www.foo.com/" ] [ "http://www.foo.com:80" >url present ] unit-test | 
					
						
							| 
									
										
										
										
											2008-09-26 19:24:58 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ f ] [ URL" /gp/redirect.html/002-7009742-0004012?location=http://advantage.amazon.com/gp/vendor/public/join%26token%3d77E3769AB3A5B6CF611699E150DC33010761CE12" protocol>> ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ | 
					
						
							|  |  |  |     T{ url | 
					
						
							|  |  |  |         { protocol "http" } | 
					
						
							|  |  |  |         { host "localhost" } | 
					
						
							|  |  |  |         { query H{ { "foo" "bar" } } } | 
					
						
							|  |  |  |         { path "/" } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | ] | 
					
						
							|  |  |  | [ "http://localhost?foo=bar" >url ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ | 
					
						
							|  |  |  |     T{ url | 
					
						
							|  |  |  |         { protocol "http" } | 
					
						
							|  |  |  |         { host "localhost" } | 
					
						
							|  |  |  |         { query H{ { "foo" "bar" } } } | 
					
						
							|  |  |  |         { path "/" } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | ] | 
					
						
							|  |  |  | [ "http://localhost/?foo=bar" >url ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "/" ] [ "http://www.jedit.org" >url path>> ] unit-test | 
					
						
							| 
									
										
										
										
											2009-04-05 21:44:12 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | [ "USING: urls ;\nURL\" foo\"" ] [ URL" foo" unparse-use ] unit-test |