Skip to content

url

roblox.utilities.url

This module contains functions and objects used internally by ro.py to generate URLs.

cdn_site

root_site

URLGenerator

Generates URLs based on a chosen base URL.

Attributes:

Name Type Description
base_url

The base URL.

Source code in roblox/utilities/url.py
class URLGenerator:
    """
    Generates URLs based on a chosen base URL.

    Attributes:
        base_url: The base URL.
    """

    def __init__(self, base_url: str):
        self.base_url = base_url

    def get_subdomain(self, subdomain: str, protocol: str = "https") -> str:
        """
        Returns the full URL of a subdomain, given the base subdomain name.

        Arguments:
            subdomain: The URL subdomain.
            protocol: The URL protocol.
        """
        return f"{protocol}://{subdomain}.{self.base_url}"

    def get_url(
            self,
            subdomain: str,
            path: str = "",
            base_url: str = None,
            protocol: str = "https",
    ) -> str:
        """
        Returns a full URL, given a subdomain name, protocol, and path.

        Arguments:
            subdomain: The URL subdomain.
            protocol: The URL protocol.
            path: The URL path.
            base_url: The base URL.
        """
        if base_url is None:
            base_url = self.base_url
        return f"{protocol}://{subdomain}.{base_url}/{path}"

__init__(self, base_url: str) special

Source code in roblox/utilities/url.py
def __init__(self, base_url: str):
    self.base_url = base_url

get_subdomain(self, subdomain: str, protocol: str = 'https') -> str

Returns the full URL of a subdomain, given the base subdomain name.

Parameters:

Name Type Description Default
subdomain str

The URL subdomain.

required
protocol str

The URL protocol.

'https'
Source code in roblox/utilities/url.py
def get_subdomain(self, subdomain: str, protocol: str = "https") -> str:
    """
    Returns the full URL of a subdomain, given the base subdomain name.

    Arguments:
        subdomain: The URL subdomain.
        protocol: The URL protocol.
    """
    return f"{protocol}://{subdomain}.{self.base_url}"

get_url(self, subdomain: str, path: str = '', base_url: str = None, protocol: str = 'https') -> str

Returns a full URL, given a subdomain name, protocol, and path.

Parameters:

Name Type Description Default
subdomain str

The URL subdomain.

required
protocol str

The URL protocol.

'https'
path str

The URL path.

''
base_url str

The base URL.

None
Source code in roblox/utilities/url.py
def get_url(
        self,
        subdomain: str,
        path: str = "",
        base_url: str = None,
        protocol: str = "https",
) -> str:
    """
    Returns a full URL, given a subdomain name, protocol, and path.

    Arguments:
        subdomain: The URL subdomain.
        protocol: The URL protocol.
        path: The URL path.
        base_url: The base URL.
    """
    if base_url is None:
        base_url = self.base_url
    return f"{protocol}://{subdomain}.{base_url}/{path}"