Pyro

A dynamically-typed, garbage-collected scripting language.

Version 0.24.0

std::url


A utility module for working with URLs.

Classes

URL() -> URL

Returns a new URL instance.

URL instances have the following public fields:

class URL {
    pub var scheme: str?;
    pub var username: str?;
    pub var password: str?;
    pub var host: str?;
    pub var port: str?;
    pub var path: str?;
    pub var query: str?;
    pub var fragment: str?;
}

URL instances have the following public methods:

:port_number() -> i64

Returns the port number as an integer.

Functions

parse_query(input: str) -> map[str, vec[str]]|err

Parses a URL-encoded query string.

  • Returns a map mapping str keys to vectors of str values.
  • Returns an err if the query string is invalidly-encoded.

The input can be a full URL — everything up to the first ? will be ignored.

parse_url(input: str) -> URL|err

Parses a URL into its component parts. Returns an err if the input is not a valid URL.

This function can parse both absolute URLs and site-relative URLs beginning with a /.

url_decode(input: str) -> str|err

Returns a new string containing the URL-decoded content of the input string. Returns an error if the input is invalidly-encoded.

url_encode(input: str) -> str

Returns a new string containing the URL-encoded content of the input string.