URL objects - Factor Documentation (original) (raw)

The urls vocabulary implements a URL data type. The benefit of using a data type to prepresent URLs rather than a string is that the parsing, printing and escaping logic is encapsulated and reused, rather than re-implemented in a potentially buggy manner every time.

URL objects are used heavily by the http and furnace vocabularies, and are also useful on their own.

The class of URLs, and a constructor:

url

( -- url )

Converting strings to URLs:

>url ( obj -- url )

URLs can be converted back to strings using the present word.

URL literal syntax:

URL"

Manipulating URLs:

derive-url ( base url -- url' )

relative-url ( url -- url' )
ensure-port ( url -- url' )
query-param ( url key -- value )
set-query-param ( url value key -- url )

Creating Address specifiers from URLs:

url-addr ( url -- addr )

The URL implementation encodes and decodes components of url instances automatically, but sometimes this functionality is needed for non-URL strings.
URL encoding and decoding

Utility words used by the URL implementation:
URL implementation utilities