std/net/url

Standard Library documentation

URL parsing, escaping, and templates.

Module

Name
std/net/url
Area
Standard Library
Source
modules/std/net/url.zzm

NAME

std/net/url - URL parsing, escaping, and templates.

SYNOPSIS

  from std/net/url import *;

  let parsed := parse(
    "https://api.example.com/v1?q=tea%20time"
  );

  let encoded := escape("tea time");
  let text := unescape(encoded);

  let url := fill_template(
    "https://api.example.com/{version}/items/{id}{?q}",
    { version: "v1", id: 7, q: "tea time" }
  );

IMPLEMENTATION SUPPORT

This module is supported by all implementations of ZuzuScript.

DESCRIPTION

This module provides small URL helpers.

EXPORTS

Functions

  • escape(value)

    Parameters: value is any value. Returns: String. Percent-encodes value for use in URLs.

  • unescape(value)

    Parameters: value is URL-escaped text. Returns: String. Decodes percent-escaped text.

  • parse(url)

    Parameters: url is a URL string. Returns: Dict. Parses url and returns a dictionary with: url, scheme, authority, userinfo, host, port, path, query, fragment, and query_params.

  • fill_template(template, values)

    Parameters: template is an RFC6570-style template and values is a dictionary or pair list. Returns: String. Fills the template using values.

COPYRIGHT AND LICENCE

std/net/url is copyright Toby Inkster.

It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.