Mozart Standard Library: URL

# URL Support

Denys Duchier

module
  x-oz://system/net/URL.ozf

This module provides an object-oriented API for URLs

## Exports

The module exports a constructor and a test:

`{URL.make +VS ?U}`
  returns a new instance `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}`
  returns true iff `X` is an instance of a URL object

## Instance API

Each URL object `U` has the following methods:

`{U init(S)}`
  initializes `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)}`
  returns respectively a virtual string, a string, or an atom for the textual representation of the URL.
  `full:true`
    indicates that full information is desired, including the possible `#FRAGMENT` and `{INFO}` sections of the URL. Normally, these are omitted.
  `cache:true`
    indicates that a syntax appropriate for cache lookup is desired. The `:` after the schme and the `//` before the authority are both replaced by a single `/`
  `raw:true`
    indicates that no encoding should take place, i.e. special url characters are not `%` encoded
  `normalized:true`
    indicates that the scheme, device and authority should all be lowercased to produce a normalized representation
`{U isAbsolute($)}`
  returns true iff the URL is absolute
`{U isRelative($)}`
  returns true iff the URL is relative, i.e. not absolute
`{U resolve(+U2 $)}`
  given another URL object `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($)}`
  returns true iff `U`'s path is empty
`{U dirname($)}`
  returns a new URL object representing the parent URL of `U`
`{U basename($)}`
  returns a new URL object representing just the last component of `U`'s path
`{U getScheme($)}`
`{U getAuthority($)}`
`{U getDevice($)}`
`{U getAbsolute($)}`
`{U getPath($)}`
`{U getQuery($)}`
`{U getFragment($)}`
`{U getInfo($)}`
  return the corresponding (typically string) element of the URL or `unit` when not available
`{U normalized($)}`
  return a new URL object which is the normalized representation of `U` (i.e. scheme, device and authority lowercased)
`{U toPath($ windows:WIN<=false)}`
  return a path object corresponding to `U`. `WIN` indicates whether it should be considered a Windows-style path