Documention for: url-handler.r
Created by: hallyhaa
on: 30-May-2007
Last updated by: hallyhaa on: 30-Jan-2009
Format: html
Downloaded on: 15-Apr-2024

Easy to use!

Construct your object like this:

 site: url-handler ""
 print site/url               ; ==

Then go somewhere else with it:

 site/move-to "docs.html"
 site/move-to ""
 site/move-to "#sect1"

What is now registered about your URL is this:

 print site/protocol              ; == "http://"
 print site/host               ; == ""
 print site/path               ; == "/docs/core23/"
 print site/file               ; == "rebolcore-1.html"
 print site/query-part                 ; == ""
 print site/section             ; == "#sect1"
 print site/canonical               ; == ""
 print site/as-string/from-path-only    ; == "/docs/core23/rebolcore-1.html"

Then what about CGI GET queries? Here:

 site: url-handler ""

Get the query as a string:

 probe site/query-part              ; == "?zz=b&hj=d&e=5&f=a%20b&sid=5&nothing=&re=bol"

Or access it as a block:

 probe site/query-block                 ; == [e: "5" f: "a b" hj: "d" nothing: none re: "bol" sid: "5" zz: "b"]

Note that the query part is sorted when in a block.

Here's almost the same URL, but note the difference in the query-part (paramters in a different order):

 site2: url-handler ""

If you tell the script to pay attention to the order in which the parameters first came in, the two URLs are not identical:

 print site2/equal?/regard-cgi-order/regard-section site ; == false

But if you disregard the cgi order, they are identical:

 print site2/equal?/regard-section site ; == true

The same goes for the /regard-section refinement. If you do not specify it, the section part of URLs will not be compared.