url(Representation) — Logtalk 3.100.1

object

# `url(Representation)`

- `Representation` - URL and is components representation. Valid values are `atom`, `codes`, and `chars`.

URL validating, parsing, and normalizing predicates following RFC3986 nomenclature.

Availability:
`logtalk_load(url(loader))`
Author: Paulo Moura
Version: 1:2:0
Date: 2026-04-17
Compilation flags:
`static, context_switching_calls`
Uses:
list
Remarks:
(none)
Inherited public predicates:
(none)

## Public predicates

### `valid/1`

True iff the argument is a valid URL, including optional query and fragment components.

Compilation flags:
`static`
Template:
`valid(URL)`
Mode and number of proofs:
`valid(++text)` - `zero_or_one`

### `parse/2`

Parses a URL into a list of its components: `[scheme(Scheme), authority(Authority), path(Path), query(Query), fragment(Fragment)]`. Fails if the URL is invalid and cannot be parsed.

Compilation flags:
`static`
Template:
`parse(URL,Components)`
Mode and number of proofs:
`parse(++text,-list(compound))` - `zero_or_one`

### `generate/2`

Generates a normalized URL from a list of its components: `[scheme(Scheme), authority(Authority), path(Path), query(Query), fragment(Fragment)]` for standard URLs, or scheme-specific components for mailto, news, tel, and urn URLs. Fails if the components are invalid.

Compilation flags:
`static`
Template:
`generate(Components,URL)`
Mode and number of proofs:
`generate(++list(compound),-text)` - `zero_or_one`

### `normalize/2`

Normalizes a URL by standardizing its components. Normalization includes converting the scheme to lowercase, percent-encoding characters that require escaping, ensuring proper path separators, and handling relative paths.

Compilation flags:
`static`
Template:
`normalize(URL,NormalizedURL)`
Mode and number of proofs:
`normalize(++text,-text)` - `one`

### `file_path_components/2`

Converts a file-system path into file URL components represented as `[authority(Authority), path(Path)]`. Windows drive-letter and UNC paths are normalized to RFC3986-compatible file URL components.

Compilation flags:
`static`
Template:
`file_path_components(FilePath,Components)`
Mode and number of proofs:
`file_path_components(++text,-list(compound))` - `one`

## Protected predicates

(no local declarations; see entity ancestors if any)

## Private predicates

### `downcase_text/2`

Converts text to lowercase (ASCII only). Only uppercase letters A-Z are converted to lowercase.

Compilation flags:
`static`
Template:
`downcase_text(Text,LowerText)`
Mode and number of proofs:
`downcase_text(+text,-text)` - `one`

## Operators

(none)