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%
Create and adjust URLs whose fragment contains hierarchical path segments and filter parameters, with control over whether a '?' separates the fragment path from its query.
https://docs.example.com/root?page=1, fragment segments ["guides", "install v1.0"], fragment params {lang: "en", step: "1"}, and the separator included, the result is https://docs.example.com/root?page=1#/guides/install%20v1.0?lang=en&step=1 @testhttps://app.example.com/#/reports?view=daily&chart=bar, adding fragment params {chart: ["line", "table"], view: "weekly"} preserves the existing fragment path and yields https://app.example.com/#/reports?view=daily&view=weekly&chart=bar&chart=line&chart=table @testchart key from https://app.example.com/#/reports?view=weekly&chart=bar&chart=line returns https://app.example.com/#/reports?view=weekly with the fragment path intact and no trailing separators @testhttps://app.example.com/dashboard, fragment segments ["reports"], and fragment params {view: "weekly", expand: "table"}, the output is https://app.example.com/dashboard#/reports&view=weekly&expand=table with no '?' between the fragment path and query parameters @test@generates
from typing import Iterable, Mapping, Sequence, Union
def build_fragment_url(
base_url: str,
fragment_segments: Sequence[str],
fragment_params: Mapping[str, Union[str, Sequence[str]]],
*,
include_separator: bool = True,
) -> str:
"""
Returns a URL where the fragment path is replaced with `fragment_segments`
and the fragment query is set from `fragment_params`. When `include_separator`
is False, no '?' appears between the fragment path and query string.
"""
def merge_fragment_params(
url: str,
*,
add: Mapping[str, Union[str, Sequence[str]]] | None = None,
remove: Iterable[str] | None = None,
) -> str:
"""
Returns a URL where the fragment query of `url` is merged with `add`
(preserving existing key order) and keys in `remove` are removed.
Does not change fragment path or base URL.
"""Handles URL parsing and fragment path/query composition with optional query separators.