tessl install tessl/pypi-furl@2.1.0URL manipulation made simple.
Agent Success
Agent success rate when using this tile
65%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.59x
Baseline
Agent success rate without this tile
41%
Compose resource URLs from decoded path segments while controlling absoluteness and directory/file hints.
reports%2F2024 remains one segment) and re-encodes reserved characters in the final URL.absolute is True, the resulting path starts with /; when False, it omits the leading slash; when None, the leading slash matches whether the base URL includes a network location.absolute flag being None.is_directory is True, the path ends with a trailing slash; when False, it omits the trailing slash even when the last segment contains dots.is_directory.is_directory is True.@generates
from collections.abc import Sequence
from typing import Optional
def build_resource_url(base_url: str, parts: Sequence[str] | str, *, absolute: Optional[bool] = None, is_directory: bool = False) -> str:
"""Compose a URL using decoded path segments with optional absolute and directory/file hints."""Provides URL parsing and path manipulation with decoded segments and absolute/dir/file flags.
"https://files.example.com/root/" with parts ["reports", "Q1", "summary.txt"] yields https://files.example.com/root/reports/Q1/summary.txt with no trailing slash when is_directory is False. @test"/workspace" with parts "reports%2F2024/" and absolute=False returns workspace/reports%2F2024/ (relative with encoded slash) and retains a trailing slash when is_directory=True. @testabsolute=True for base "./" and parts ["media", "clips", "final"] produces /media/clips/final/ when is_directory=True, ensuring redundant slashes are removed. @test