Skip to content

wasat.uri

Gemini URI representation and parsing.

GeminiURI

GeminiURI(uri: str | Self)

Represents a validated Gemini protocol URI.

Parameters:

Name Type Description Default

uri

str | Self

The raw URI string or an existing GeminiURI to clone.

required

Raises:

Type Description
URIError

If the URI is invalid or has an incorrect scheme.

host property

host: str

The target hostname.

path property

path: str

The resource path (defaults to '/').

port property

port: int

The target port (defaults to GEMINI_DEFAULT_PORT).

query property

query: str | None

The query string or None.

scheme property

scheme: str

The URI scheme (always 'gemini').

__hash__

__hash__() -> int

Return the hash value of the URI.

__str__

__str__() -> str

Return the string representation of the URI.

resolve

resolve(relative_uri: str) -> Self

Resolve a relative URI string against this URI as a base.

Parameters:

Name Type Description Default

relative_uri

str

The relative or absolute target URI string.

required

Returns:

Type Description
Self

A new GeminiURI representing the resolved target.

Raises:

Type Description
URIError

If the resolved URI is invalid.

with_query

with_query(query: str) -> Self

Return a new GeminiURI with the query parameter replaced or set.

Parameters:

Name Type Description Default

query

str

The new query string (will be URL-encoded).

required

Returns:

Type Description
Self

A new GeminiURI instance with the updated query.