URL manipulation made simple.
65
Build API request URLs from a base template with safe path joining, configurable serialization, cloning for variant URLs, and component export for logging.
https://api.example.com/root/ with default query token=abc, joining path segments v1, users, 42 plus extra query expand=true produces https://api.example.com/root/v1/users/42?token=abc&expand=true, and the base instance remains unchanged for reuse. @testhttps://api.example.com/base with query note=space here and mode=raw, serializing with delimiter ; and spaces encoded as %20 returns https://api.example.com/base?note=space%20here;mode=raw. @testhttps://api.example.com/root?token=abc and then adding debug=true to only the original results in different outputs: the clone keeps https://api.example.com/root?token=abc while the original becomes https://api.example.com/root?token=abc&debug=true. @testhttps, host api.example.com, port 443, path segments ['root', 'v1', 'users', '42'], and ordered query pairs [('token', 'abc'), ('expand', 'true')]. @test@generates
class ServiceUrl:
def __init__(self, base_url: str, default_query: dict[str, str] | None = None): ...
def compose(self, *segments: str, query: dict[str, str] | None = None) -> "ServiceUrl": ...
def as_string(self, delimiter: str = "&", quote_plus: bool = True, dont_quote: str = "") -> str: ...
def clone(self) -> "ServiceUrl": ...
def to_record(self) -> dict: ...Python URL manipulation utility for building, joining, copying, and serializing URLs.
Install with Tessl CLI
npx tessl i tessl/pypi-furlevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10