Denys Duchier
This module provides an object-oriented API for URLs
The module exports a constructor and a test:
{URL.make +VS ?U}
U
of a URL object, given a virtual
string VS
. If VS
is actually already a URL object
then it is simply returned
{URL.is +X ?B}
X
is an instance of a URL object
Each URL object U
has the following methods:
{U init(S)}
U
given a string S
{U toVS( $ full:FULL<=false cache:CACHE<=false raw:RAW<=false normalized:NORM<=false)}
{U toString($ full:FULL<=false cache:CACHE<=false raw:RAW<=false normalized:NORM<=false)}
{U toAtom( $ full:FULL<=false cache:CACHE<=false raw:RAW<=false normalized:NORM<=false)}
full:true
#FRAGMENT
and {INFO}
sections of the URL.
Normally, these are omitted.
cache:true
:
after the schme and the //
before the
authority are both replaced by a single /
raw:true
%
encoded
normalized:true
{U isAbsolute($)}
{U isRelative($)}
{U resolve(+U2 $)}
U2
as an argument, returns
a new URL object which results from resolving U2
relative to
U
. Note that U
is considered as a whole, not
just its base
{U isRoot($)}
U
's path is empty
{U dirname($)}
U
{U basename($)}
U
's path
{U getScheme($)}
{U getAuthority($)}
{U getDevice($)}
{U getAbsolute($)}
{U getPath($)}
{U getQuery($)}
{U getFragment($)}
{U getInfo($)}
unit
when not available
{U normalized($)}
U
(i.e. scheme, device and authority lowercased)
{U toPath($ windows:WIN<=false)}
U
. WIN
indicates whether it should be considered
a Windows-style path