Logo Decentralized Social Network

moeralib.universal_location

Constants

REDIRECTOR = "moera-page"

Host used as redirector in universal URLs.

Functions

parse(url)

Parse the location part (including query and fragment) of a universal URL.

Parameters:
urlstr | None – the URL to be parsed
Return value:
UniversalLocation – the parsed location

redirect_to_url(node_name, url=None)

Build a universal Moera URL from the direct URL of a page on a node, adding the node name provided.

Parameters:
node_namestr | None – the node name
urlstr | None(optional) the direct URL
Return value:
str – the universal URL

redirect_to(node_name, root_url, path=None, query=None, fragment=None)

Build a universal Moera URL from the node name, the Moera root URL of the node, virtual path and other components.

Parameters:
node_namestr | None – the node name
root_urlstr | None – the Moera root URL of the node
pathstr | None(optional) virtual path at the node ('/', if set to None or empty)
querystr | None(optional) query component of the URL
fragmentstr | None(optional) fragment identifier of the URL
Return value:
str – the universal URL

UniversalLocation

Represents location part of a universal Moera URL.

node_name

str | None – The node name.

scheme

str – Scheme specifier of the node location.

authority

str | None – Authority (host name and optional port) of the node location.

path

str | None – Virtual path at the node.

location

str(read only) Universal Moera location (without query and fragment).

query

str | None – Query component of the URL.

fragment

str | None – Fragment identifier of the URL.

UniversalLocation(node_name=None, scheme=None, authority=None, path=None, query=None, fragment=None)

Parameters:
node_namestr | None(optional) the node name
schemestr | None(optional) scheme specifier of the node location ('https', if set to None or empty)
authoritystr | None(optional) authority (host name and optional port) of the node location
pathstr | None(optional) virtual path at the node ('/', if set to None or empty)
querystr | None(optional) query component of the URL
fragmentstr | None(optional) fragment identifier of the URL